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:
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.