如何在Jetpack Compose中将可绘资源设置为
Image
的背景?对应的视图XML代码是什么?
Corresponding view XML code
对应的视图XML代码<androidx.appcompat.widget.AppCompatImageView
android:background="@drawable/drawable_black_circle"
android:src="@drawable/app_logo"
...
/>
我的当前代码,
Image(
painter = painterResource(id = R.drawable.app_logo),
contentDescription = null,
modifier = Modifier
.height(160.dp)
.width(160.dp)
.padding(32.dp),
)
Modifier.background()
让我可以将颜色用作背景。
类似地,我正在寻找一种使用可绘制资源作为背景的方法。
注意:
我正在寻找一种将图像用作背景的方法。
不要求将图像包含在具有背景的另一个组件中。