我在drawable文件夹中有一个xml形状
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="0dp" />
<solid android:color="@color/very_light_gray" />
<stroke
android:width="1dip"
android:color="@color/dark_gray" />
</shape>
如何以编程方式更改very_light_gray
和dark_gray
颜色?
有什么办法吗?
这是否可以覆盖形状类并使用覆盖的类而不是xml中的形状?
答案 0 :(得分:1)
您可以修改它。
GradientDrawable bgShape = (GradientDrawable)yourView.getBackground();
bgShape.setColor(Color.WHITE);