hey i’ve been playing with compose recently, and h...
# compose
s
hey i’ve been playing with compose recently, and have a short question. I want to render the vector asset inside the row. Currently i’m doing smth like this:
Copy code
Row(modifier = Modifier.fillMaxHeight() + Modifier.fillMaxWidth()) {
    if (stateChecked.value) {
        VectorPainter(asset = vectorResource(id = R.drawable.ic_checkbox_on))
    } else {
        VectorPainter(asset = vectorResource(id = R.drawable.ic_checkbox_off))
    }
}
However, it doesn’t show anything on the screen. Is that approach correct, at all?
k
Not sure if this is correct, but I'm using Icon:
Copy code
Icon(asset = VectorResource(R.drawable.ic_outline_menu_24))
as suggested in this thread: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1584849322105100
s
Thanks, it works 👍 I thought maybe i had some issue with my modifier.
a
you can write
Copy code
Modifier.fillMaxHeight() + Modifier.fillMaxWidth()
as
Copy code
Modifier.fillMaxHeight()
    .fillMaxWidth()
now 🙂
🔝 1
(or even just
Modifier.fillMaxSize()
)
s
nice 👏 thank you!
s
do you know how to resize the vector icon more bigger ?
Copy code
Box(gravity = ContentGravity.Center, modifier = Modifier.fillMaxSize()) {
    Icon(asset = vectorResource(R.drawable.ic_favorite))
}
k
You can apply this modifier to your Icon:
Copy code
Modifier.preferredSize(60.dp, 60.dp)