[英]Is there a way to perform Matrix Scale for Jetpack Compose Image?
In XML based image, we can have matrix scale type as per https://medium.com/mobile-app-development-publication/android-matrix-scaletype-explained-4501f0796be8 , which is a very powerful custom scale type one can perform on an Image.在基于 XML 的图像中,我们可以根据https://medium.com/mobile-app-development-publication/android-matrix-scaletype-explained-4501f0796be8具有矩阵比例类型,这是一种可以执行的非常强大的自定义比例类型在图像上。
However, in JetpackCompose image, we no longer have Matix Scale.但是,在 JetpackCompose 图像中,我们不再有 Matix Scale。 Instead the contentScale
而是contentScale
Image(imagePicture,
contentDescription = null,
modifier = Modifier.fillMaxSize(),
alignment = alignment.alignment,
contentScale = scale.scaleType // the scale here
)
Only have those as listed here https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/ContentScale , ie Crop, Fit, FillWidth, FillHeight, FillBounds, Fit, Inside, and None.只有此处列出的https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/ContentScale ,即 Crop、Fit、FillWidth、FillHeight、FillBounds、Fit、Inside 和 None。
How can I achieve Matrix Scale in JetpackCompose?如何在 JetpackCompose 中实现矩阵缩放?
The behavior you are looking for, is achievable with graphicsLayer
:您正在寻找的行为可以通过graphicsLayer
实现:
val imageBitmap = imageResource(id = R.drawable.cover)
Image(imageBitmap, contentDescription = "Test", modifier = Modifier
.graphicsLayer {
translationX = 0.4f
translationY = 0.4f
rotationY = 53f
rotationX = 44f
rotationZ = 23f
scaleX = 0.4f
scaleY = 0.5f
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.