Ely*_*lye 5 android kotlin android-jetpack-compose
我使用的是 jetpack compose 1.0.0-alpha 11。以下代码有效。
Image(
imageResource(R.drawable.header),
contentDescription = null,
modifier = itemModifier,
contentScale = ContentScale.Crop
)
Run Code Online (Sandbox Code Playgroud)
然而在jetpack compose 1.0.0-beta07中,imageResource并且vectorResource起作用。
获取图片资源的新方式是什么?
您1.0.x可以使用该painterResource功能:
Image(painterResource(R.drawable.ic_xxxx),"content description")
Run Code Online (Sandbox Code Playgroud)
这可以分别加载基于资产BitmapPainter或基于矢量的资产的实例。
此方法适用于图像(PNG 或 JPG 文件)或xml 资源。VectorPainterImageBitmapVectorDrawable
关于使用ImageBitmap.imageResource(R.drawable.header)
此函数旨在用于需要低级
ImageBitmap特定功能时。painterResource为了简单地在屏幕上显示,建议使用矢量/位图无关的。
| 归档时间: |
|
| 查看次数: |
3993 次 |
| 最近记录: |