Can I make Window `wrap_content`?
# compose-desktop
g
Can I make Window
wrap_content
?
👀 2
i
Try this:
Copy code
fun main() = Window(size = IntSize.Zero, undecorated = true) {
    val window = AppWindowAmbient.current!!
    val density = DensityAmbient.current

    Box(
        Modifier
            .sizeIn(maxWidth = Dp.Infinity, maxHeight = Dp.Infinity)
            .onSizeChanged {
                with(density) {
                    window.setSize(
                        it.width.toDp().value.toInt(),
                        it.height.toDp().value.toInt()
                    )
                    window.window.isResizable = false
                }
            }
    ) {
        Text("Text", style = TextStyle(fontSize = 300.sp))
    }
}
I am using undecorated = true here. For decorated Window there is a small glitch at the start of the application (we can see "Window with zero size" for a few milliseconds)
👍 1
g
Hm, strange, but window is a little bit bigger then
Text
(I highlighted
Box
background)
@Igor Demin your lastest changes helped, thank you!
👍 2