如何将元素居中嵌入在行内的第一列中:
<<class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { MaterialTheme { Row { Column(modifier = LayoutPadding(top = 16.dp)) { Text(text = "Centered ", style = TextStyle(fontSize = 30.sp, fontWeight = FontWeight.Bold)) } Column { Text(text = "Line One ", style = TextStyle(fontSize = 30.sp, fontWeight = FontWeight.Bold)) Text(text = "Line Two ", style = TextStyle(fontSize = 30.sp, fontWeight = FontWeight.Bold)) } } } } } }
在此示例中,我对填充进行了硬编码,但无法弄清楚如何将元素居中放置在框外。如果没有这样的选择,如何获得整个行的高度?
Container(alignment = Alignment.TopCenter)或Center {}将为您提供帮助。