Reputation: 463
I am trying to scale icon width by height. I was trying to add contentScale modifier, but it doesn't know it.
Icon(
painter = painterResource(id = id),
contentDescription = null,
tint = Color.White,
//contentScale = ContentScale.Fit,
modifier = Modifier .fillMaxHeight(0.6f)
.align(CenterVertically).border(2.dp,Color.Black, RectangleShape)
)
Picture how it looks - The icon on the left should be scaled to fit height of the black box:
Upvotes: 1
Views: 3329
Reputation: 4823
Ensuring your icon is a square should be sufficient.
Modifier
.fillMaxHeight(0.6f)
.aspectRatio(1f) // make the width same as the height
... // your other modifiers
Upvotes: 2