例如,我有这段代码:
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="1dip"
android:color="#000000"/>
</shape>
如何更改android:color
的价值?
由于
答案 0 :(得分:0)
您可以在运行时创建它,然后随时更改它:
RoundRectShape rect = new RoundRectShape(
new float[] {30,30, 30,30, 30,30, 30,30},
null,
null);
ShapeDrawable bg = new ShapeDrawable(rect);
bg.getPaint.setColor(0x99FFFFFF);
view.setBackgroundDrawable(bg);