Ely*_*lye 6 android android-jetpack-compose
在基于 XML 的图像中,我们可以按照https://medium.com/mobile-app-development-publication/android-matrix-scaletype-explained-4501f0796be8拥有矩阵缩放类型,这是一种可以执行的非常强大的自定义缩放类型在图像上。
然而,在 JetpackCompose 图像中,我们不再有 Matix Scale。相反,contentScale
Image(imagePicture,
contentDescription = null,
modifier = Modifier.fillMaxSize(),
alignment = alignment.alignment,
contentScale = scale.scaleType // the scale here
)
Run Code Online (Sandbox Code Playgroud)
仅具有此处列出的https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/ContentScale,即 Crop、Fit、FillWidth、FillHeight、FillBounds、Fit、Inside 和 None。
如何在 JetpackCompose 中实现 Matrix Scale?
您正在寻找的行为可以通过以下方式实现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
})
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1476 次 |
最近记录: |