【问题标题】:Android Jetpack Compose: All row items not rendering on smaller screensAndroid Jetpack Compose:所有行项目未在较小的屏幕上呈现
【发布时间】:2021-01-24 19:35:07
【问题描述】:

我仍在使用 Android 的 Jetpack Compose 声明式 UI 库,希望能得到一些帮助。该列(包含图像“图标”和文本)根本不会在较小的屏幕上呈现。这是相关代码-->

@Composable
fun ComposableExample() {
...
ScrollableColumn(modifier = Modifier.fillMaxWidth()) {
    // Scrollable column should have one child.
    Column {
        
        Row(
            modifier = Modifier.fillMaxWidth(),
            verticalAlignment = Alignment.CenterVertically,
        ) {
            
            Text(text = "This is the Title of the Video")
            
            //--------- This column is rendering on wider (tablet+) screens but not phone sized screens.
            Column(horizontalAlignment = Alignment.CenterHorizontally,
                modifier = Modifier.fillMaxWidth()) {
                Image(imageResource(id = R.drawable.icon_download_arrow),
                    modifier = Modifier.preferredSize(20.dp)
                        .clickable(onClick = { }))
                Text(text = "Download")
            }
            // ---------
            
        }
            ...
    }
}
}

我尝试了大量不同的修饰符/排列,但无法让列在较小的屏幕上呈现。非常感谢您的帮助,谢谢!

【问题讨论】:

    标签: android android-layout kotlin android-jetpack android-jetpack-compose


    【解决方案1】:

    只需交换列,文本就可以工作,即在视频标题之前呈现图标图像和文本的可点击列。不完全确定为什么会这样,但确实如此!

    【讨论】:

      猜你喜欢
      • 2022-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-16
      • 1970-01-01
      • 2022-07-26
      • 2022-08-18
      • 2017-02-16
      相关资源
      最近更新 更多