0

我希望小部件正确对齐,但使用单列。还有其他方法可以对齐这些项目吗?

代码:

Column(LayoutPadding(20.dp)) {
    Align(alignment = Alignment.TopRight) {
        Text(text = "0")
        Text(text = "testOperation")
    }
}

结果:

(RIGHT ALIGNED) 0

预期的:

(RIGHT ALIGNED) 0 
(RIGHT ALIGNED) testOperation
4

2 回答 2

0

You should try like this,

        Align(alignment = Alignment.TopRight) {
            Column(LayoutPadding(20.dp)){
                Text(text = "0")
                Text(text = "testOperation")
            }
        }

Or like this, depending on your usage.

    Column(LayoutPadding(20.dp)) {
        Align(alignment = Alignment.TopRight) {
            Column(){
                Text(text = "0")
                Text(text = "testOperation")
            }
        }
    }

You can align each Text using Alignment.TopRight, BottomRight and so on.

Column(LayoutPadding(20.dp)) {
    Column(){
        Text(text = "0")
        Align(alignment = Alignment.TopRight) {
            Text(text = "testOperation")
        }
    }
}
于 2020-03-06T02:14:02.783 回答
0

只需1.0.0-beta03使用类似的东西:

Column(
        modifier = Modifier.fillMaxWidth(),
        verticalArrangement = Arrangement.Top,
        horizontalAlignment = Alignment.End
) {
    Column (){
        Text(
                text = "First item",
                modifier = Modifier.padding(16.dp)
        )
        Text(
                text = "Second item",
                modifier = Modifier.padding(16.dp)
        )
        Text(
                text = "Third item",
                modifier = Modifier.padding(16.dp)
        )
    }
}

在此处输入图像描述

于 2020-06-02T12:48:37.633 回答