https://kotlinlang.org logo
#compose
Title
# compose
m

Muh Rahmatullah

11/18/2019, 4:26 PM
hi all, is there any straightforward way to show image with custom width and height? currently I am using
SimpleImage
wrapped inside a
Container
. code like this
Copy code
Container(width = 62.dp, height = 42.dp) {
                SimpleImage(image = image)
            }
b

Bruno_

11/18/2019, 5:10 PM
how about copying the SimpleImage implementation and tweaking it?
Copy code
@Composable
fun SimpleImage(
    image: Image,
    tint: Color? = null
) {
    // TODO b/132071873: WithDensity should be able to use the DSL syntax
    WithDensity(block = {
        Container(width = image.width.toDp(), height = image.height.toDp()) {
            DrawImage(image, tint)
        }
    })
}
m

Muh Rahmatullah

11/18/2019, 5:18 PM
I think that could work, lemme try, thanks
a

Anna-Chiara Bellini [G]

11/18/2019, 6:55 PM
m

Muh Rahmatullah

11/19/2019, 4:53 AM
Thanks, looking at it now