Код: Выделить всё
@Preview(showBackground = true)
@Composable
fun ItemView() {
val names = listOf("Captain" to "Vice Captain")
LazyColumn(modifier = Modifier.fillMaxSize()) {
itemsIndexed(names) { index, item ->
var titleCoordinates by remember { mutableStateOf(null) }
Column(
modifier = Modifier
.fillMaxWidth()
.drawBehind {
val titleBounds = titleCoordinates?.boundsInParent()
if (titleBounds != null) {
val offset = Offset(x = center.x / 2, y = titleBounds.top)
drawLine(
color = Color.Black,
start = offset,
end = offset.copy(y = size.height),
strokeWidth = 2.dp.toPx(),
)
}
}
) {
Box(
Modifier
.padding(top = 24.dp)
.onGloballyPositioned { titleCoordinates = it }
) {
Text(text = item.first, color = Color.Red)
}
Text(text = item.second, color = Color.Blue)
}
}
}
}
[img]https://i. sstatic.net/2cOKi.png[/img]
Я могу добавить отступы (start = 120.dp) в столбец, чтобы получить результат ниже. Я хочу избежать этих дополнений. Можно ли добиться результата ниже?
Ожидаемый результат
Большое спасибо
Подробнее здесь: https://stackoverflow.com/questions/761 ... ck-compose
Мобильная версия