【发布时间】:2021-10-07 17:18:46
【问题描述】:
在左对齐 Imageview 和在右对齐 3 textview,这样图像的高度取决于纵横比,第一个文本视图应与 imageview 的顶部对齐,第三个 textview 的底部应与底部对齐的图像。这两个文本视图之间的空间应该给第二个文本视图。
@Preview
@Composable
fun ShowUi() {
Row
modifier = Modifier
.padding(10.dp)
.wrapContentHeight()
.fillMaxWidth()
) {
Box(
modifier = Modifier
.weight(7f)
.aspectRatio(1.77f)
.background(Color.Yellow)
) {
}
Column(
modifier = Modifier
.weight(3f)
.background(Color.Green)
) {
Text(
text = "Title 1",
fontSize = 20.sp,
maxLines = 1,
modifier = Modifier.background(Color.Green)
)
Text(
text = "You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.",
overflow = TextOverflow.Ellipsis,
modifier = Modifier.background(Color.Gray),
)
Text(
text = "PLAY NOW",
modifier = Modifier.background(Color.Green),
maxLines = 1
)
}
}
}
注意:不能在第二个 TextView 中使用 maxLines,因为可以显示的行数是动态的,即取决于第一和第三个 textview 之间的可用空间。
【问题讨论】:
标签: kotlin android-layout android-jetpack-compose android-jetpack