[英]Is it possible to "Scale" width and height any widget in jetpack compose?
[英]How to scale icon width by height in Jetpack Compose
我正在嘗試按高度縮放圖標寬度。 我試圖添加 contentScale 修飾符,但它不知道。
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)
)
確保您的圖標是正方形就足夠了。
Modifier
.fillMaxHeight(0.6f)
.aspectRatio(1f) // make the width same as the height
... // your other modifiers
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.