Row {
TextField(
value = "Test Test Test Test Test Test Test Test Test Test Test Test" +
" Test Test Test Test Test Test Test Test ",
onValueChange = {},
modifier = Modifier.weight(1f)
)
TextField(
value = "Test Test Test Test Test Test TesTest Test Test Test " +
"Test Test Test Test Test Test Test Test Test ",
onValueChange = {},
modifier = Modifier.weight(1f)
)
}
Box(modifier = Modifier.fillMaxWidth()) {
var size by remember { mutableStateOf(Size.Zero) }
val height: @Composable () -> Dp = { with(LocalDensity.current) { size.height.toDp() } }
Text(
text = longText,
modifier = Modifier
.padding(8.dp)
.fillMaxWidth(.45F)
// if second text is larger than first text call it on second text
.onGloballyPositioned { size = it.size.toSize() },
textAlign = TextAlign.Justify
)
Divider(
modifier = Modifier
.width(1.dp)
.height(height())
.align(Alignment.Center),
color = Color.Black
)
Text(
text = longText,
modifier = Modifier
.padding(8.dp)
.align(Alignment.TopEnd)
.fillMaxWidth(.45F),
textAlign = TextAlign.Justify
)
}
3条答案
按热度按时间ifmq2ha21#
使用重量
xienkqul2#
可以使用
row
并设置修改器weight: 1f
:如果您希望在下一行中有第二个TextField(如果它正在换行),则可以使用FlowRow
https://google.github.io/accompanist/flowlayout
nuypyhwy3#
看看这个,这可以通过使用box来完成。