【发布时间】:2020-06-09 19:48:21
【问题描述】:
如何将Row 中的元素按基线对齐。我的问题是我想要一个带有多个 Text 元素的 Row 元素,并且每个 Text 元素将具有不同的字体和大小。默认情况下,它们在顶部对齐。我需要它们在底部对齐。这是代码:
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MaterialTheme {
Row {
Text(
text = "Abrakadabra",
style = TextStyle(fontSize = 22.sp, fontWeight = FontWeight.Bold)
)
Text(
text = "Abrakadabra",
style = TextStyle(fontSize = 14.sp, fontWeight = FontWeight.Bold)
)
}
}
}
}
}
这是代码的渲染视图:
【问题讨论】:
标签: android android-layout kotlin android-jetpack android-jetpack-compose