Как сказать «Положение абсолютное и нижнее 0%» в JetPack Compose? что на первый взгляд кажется правильным решением. Однако модификатор Offset не выводит элемент из фактического потока структуры и не может правильно применить модификатор Zindex .
Я создал два пользовательских модификатора. Это отлично работает при создании простого поп-диалога, но на самом деле не работает как Absolute свойство в CSS. Я хочу создать несколько позиционных элементов Absolute , но это решение не допускает этого.
Код: Выделить всё
/**
* Fullscreen allows to create a box that overlays the whole screen.
*/
@Composable
fun Fullscreen(
modifier: Modifier = Modifier,
content: @Composable () -> Unit
) {
Popup (
onDismissRequest = {},
) {
Box(
modifier = modifier
.fillMaxSize()
) {
content()
}
}
}
// =============
/**
* Composable that allows to place content in a specific position.
*/
@Composable
fun InPosition(
x: Int,
y: Int,
content: @Composable () -> Unit
) {
Layout(
content = content,
measurePolicy = { measurables, constraints ->
// Use the max width and height from the constraints
val width = constraints.maxWidth
val height = constraints.maxHeight
ScreenSize.value = Pair(width, height)
val placeables = measurables.map { measurable ->
measurable.measure(constraints)
}
layout(width, height) {
placeables.forEach { placeable ->
placeable.place(x, y)
}
}
}
)
}
< /code>
Вот небольшой пример: < /p>
"
I don't care the regular flow of the document.
class="absolute bg-[#a646f573] z-20 text-black top-4 left-20 p-2 text-white"
>
I don't care too :>
I'm under the boxes you can display me by increasing the z-index.
Я пытаюсь сделать то же самое, что и приведенный выше код в Jetpack Compose.
Подробнее здесь: https://stackoverflow.com/questions/797 ... ck-compose
Мобильная версия