2 回答

四季花海
TA贡献1811条经验 获得超5个赞
如果你想改变背景图像的颜色即你设置使用setBackgroundResource
然后使用
setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(context, R.color.black)));

largeQ
TA贡献2039条经验 获得超8个赞
假设您要将可绘制对象设置为前景并将颜色设置为背景,您将需要一个 ImageView。您可以直接从 xml 中设置它:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/black"
android:src="@drawable/my_awesome_drawable" />
或者像这样以编程方式:
imageView.background = resources.getDrawable(R.color.black)
imageView.setImageResource(R.drawable.my_awesome_drawable)
添加回答
举报
0/150
提交
取消