转自:http://www.jianshu.com/p/5353745f07db
Android中Shape经常会被用到,今天遇到个问题,要动态修改Shape的背景颜色,记录一下.
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="5dp" />
<solid android:color="@color/white" />
</shape>
代码:
GradientDrawable drawable =(GradientDrawable)view.getBackground();
drawable.setColor(getResources().getColor(color));