Код: Выделить всё
@Composable
fun SomeAnimatedVisibility(
visible: Boolean,
modifier: Modifier = Modifier,
// ...
content: @Composable () -> Unit
) {
val graphicsLayer = rememberGraphicsLayer()
var bounds by remember {
mutableStateOf(Rect.Zero)
}
LaunchedEffect(visible) {
if (graphicsLayer.size.toSize() == Size.Zero) return@LaunchedEffect
val bitmap = graphicsLayer.toImageBitmap().asAndroidBitmap()
.copy(Bitmap.Config.ARGB_8888, false)
// Do something cool with the bitmap
}
Layout(
content = content,
modifier = modifier
.drawWithContent {
graphicsLayer.record {
this@drawWithContent.drawContent()
}
if (visible) {
drawLayer(graphicsLayer)
}
}
.onGloballyPositioned {
bounds = it.boundsInRoot()
},
measurePolicy = { measurables, constraints ->
if (!visible) {
return@Layout layout(0, 0) {}
}
val placeables = measurables.fastMap { it.measure(constraints) }
val maxWidth: Int = placeables.fastMaxBy { it.width }?.width ?: 0
val maxHeight = placeables.fastMaxBy { it.height }?.height ?: 0
layout(maxWidth, maxHeight) {
placeables.fastForEach {
it.place(0, 0)
}
}
}
)
}
, я также попробовал все возможное, но в Bitmap> inposeeree -vired intosire -virede intosire -viredible intesire -virece in inposeeree in inposeeree in in in in in inposeeree in inposeeree- он всегда измеряет с шириной 0 и высотой.>
Подробнее здесь: https://stackoverflow.com/questions/796 ... -to-screen
Мобильная версия