Search code examples
androidandroid-jetpack-compose

How to tied bottom of the Image to the bottom of Text in Compose?


I have Image and Text.

Text has specified fontSize 30.sp and top padding 25.dp How to make Image having no paddings, but bottom of the Image should be tied to bottom of the Text?

So that Image wouldn't appear below Text and by changing the height of Text would have similar impact on positioning of Image.

enter image description here


Solution

  • You just need to combine them in a Row and set the Verticle Alignment like below

    Row(verticalAlignment = Alignment.Bottom) {
        Image(painter = painterResource(id = R.drawable.img_sample), contentDescription = "")
        Text(text = "A SAMPLE TEXT")
    }