Android中Shape常常会被用到,今天遇到个问题,要动态修改Shape的背景颜色,记录一下.android
<shape xmlns:android="http://schemas.android.com/apk/res/android"> <corners android:radius="5dp" /> <solid android:color="@color/white" /> </shape>
代码:code
GradientDrawable drawable =(GradientDrawable)view.getBackground(); drawable.setColor(getResources().getColor(color));
做者:程序亦非猿
连接:https://www.jianshu.com/p/5353745f07db
來源:简书
著做权归做者全部。商业转载请联系做者得到受权,非商业转载请注明出处。xml