0

例如,我有这个代码:

<shape 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle">
        <stroke 
            android:width="1dip" 
            android:color="#000000"/>
</shape>

如何更改 的值android:color

谢谢

4

1 回答 1

1

您可以在运行时创建它,然后随时更改它:

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);
于 2013-10-22T15:37:46.603 回答