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