Thread
#compose
    Miguel A. Ruiz

    Miguel A. Ruiz

    2 years ago
    Hi, I have a question, I hope I can explain it properly. I want to show an image with the height fixed (I use a container with a height in dp for that) but I would like to have a width dependent of the image size, I mean to respect the image ratio. How can I achieve that?
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    2 years ago
    There used to be an
    AspectRatio
    composable, but I think it recently got turned into a modifier
    Miguel A. Ruiz

    Miguel A. Ruiz

    2 years ago
    thanks, that works!
    just in case somebody need it. With the version dev05. As you see now this is
    LayoutAspectRatio
    val image = imageResource(R.drawable.war_and_peace)
        val ratio = image.width.toFloat() / image.height.toFloat()
        Container(
            modifier = LayoutHeight.Constrain(0.dp, 120.dp)
                    + LayoutAspectRatio(aspectRatio = ratio)
        ) {
            DrawImage(image)
        }