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

henrikhorbovyi

06/22/2020, 3:17 PM
Hey everyone... I'm trying to change the size of a drawable but it does not work 🤔 I'm trying >>>
Copy code
Image(
     asset = vectorResource(id = R.drawable.ic_android),
     modifier = Modifier.size(56.dp),
     colorFilter = ColorFilter.tint(Color.Red)
)
s

samueldple

06/22/2020, 5:10 PM
On the asset (end of your vectorResource function), call copy() and set the defaultWidth and defualtHeight
Copy code
asset = vectorResource(id = R.drawable.ic_android).copy(defaultWidth = 56.dp, defaultHeight = 56.dp),
h

henrikhorbovyi

06/22/2020, 6:14 PM
Thank you @samueldple 🙂
s

samueldple

06/22/2020, 9:39 PM
You're welcome 🙂
v

Vinay Gaba

06/22/2020, 10:25 PM
I’ve noticed this too. Curious about why Modifier.size doesn’t work for image assets. Intuitively, using the modifier would be my first instinct.
h

henrikhorbovyi

06/22/2020, 10:36 PM
Yeah @Vinay Gaba
It just made me very curious
m

Mihai Popa

06/23/2020, 2:15 PM
I agree that the size should be settable with modifiers - could you please file a bug?
✔️ 1
n

Nader Jawad

06/27/2020, 5:41 AM
The optional ContentScale parameter can be provided for the Image composable. By default it is set to ContentScale.Inside which will scale the content down if it is larger than the composable size but render it as is if it is smaller than the composable area. Try using ContentScale.Fit to scale the content up to the maximum size to fit within the provided layout bounds or ContentScale.Crop to fill the larger of the width or height
🙌 1
☝️ 1
h

henrikhorbovyi

06/28/2020, 3:36 PM
Thank you @Nader Jawad