如何在 jetpack 中正确旋转文本并使其进行正确的布局?当我rotate在文本对象上使用修饰符时,文本会旋转,但布局中占用的大小似乎使用预旋转的文本宽度。
这是我想要完成的一个简单示例 - 垂直文本应该位于狭窄空间的左侧:
@Composable
fun MainBox() {
Column(
modifier = Modifier.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(
modifier = Modifier.padding(4.dp).background(Color.Gray),
text = "This is at the top"
)
Row(
modifier = Modifier.fillMaxWidth().weight(1f),
verticalAlignment = Alignment.CenterVertically
) {
Text(
modifier = Modifier.padding(4.dp).rotate(-90f),
text = "This should be vertical text on the left side"
)
Text(
modifier = Modifier.fillMaxSize().background(Color.Yellow),
textAlign = TextAlign.Center,
text = "This is a big yellow box that should take up most of the …Run Code Online (Sandbox Code Playgroud)