https://kotlinlang.org logo
Title
c

clark

05/20/2023, 6:47 PM
Hi there, I'm trying to build a screen like this and it works fine in two player mode (see the video) because when it's rotated 180 degrees the dimensions are the same, but the 4 player mode (see the screenshot) is giving me a hard time. I know that the graphics layer is what does the rotation, so it doesn't adjust the layout after rotation, but I was wondering if anyone could help me figure out a way to get it to work. Thanks in advance!
a

Albert Chang

05/22/2023, 2:54 AM
You can use something like:
Modifier
    .layout { measurable, constraints ->
        val placeable = measurable.measure(
            Constraints.fixed(width = constraints.maxHeight, height = constraints.maxWidth)
        )
        layout(constraints.maxWidth, constraints.maxHeight) {
            placeable.place(
                (constraints.maxWidth - placeable.width) / 2,
                (constraints.maxHeight - placeable.height) / 2
            )
        }
    }
    .rotate(90f)
c

clark

05/22/2023, 9:58 PM
This works great! Thanks so much!