GradienDrawable可以改变xml中shape的属性
来源:互联网 发布:icloud删除的数据恢复 编辑:程序博客网 时间:2024/06/08 02:14
要在代码中改变xml文件中shape属性,可以用GradienDrawable,例如我给一个button自定义了一个背景,名small_button
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="@color/background_primary"/> <stroke android:width="2dp" android:color="@color/red_primary"/> <corners android:radius="10dp"/></shape>
,然后给button设置
android:background="@drawable/small_shape"
但是想实现动态变化背景色,所以需要在代码中改变背景色,但是不改变我设置的其他样式,比如边框颜色和圆弧角,
GradientDrawable mgd = (GradientDrawable) button.getBackground();//这里先设置改背景mgd.setColor(ContextCompat.getColor(context,backgroundColor));//这里设置改背景的颜色
0 0
- GradienDrawable可以改变xml中shape的属性
- Android中xml中shape的属性助记
- Android中xml中shape的属性助记
- android中shape的属性
- Android中shape的属性
- XML中shape的使用
- android中通过自定义xml实现你需要的shape效果 xml属性配置
- android中通过自定义xml实现你需要的shape效果 xml属性配置
- android中通过自定义xml实现你需要的shape效果 xml属性配置
- android中通过自定义xml实现你需要的shape效果 xml属性配置
- android中通过自定义xml实现你需要的shape效果 xml属性配置
- android中通过自定义xml实现你需要的shape效果 xml属性配置
- android中通过自定义xml实现shape效果 的属性配置
- RecyclerView可以在xml文件中配置的特别属性
- Android shape属性在xml中自定义边框
- android中shape的属性大全
- Android 中shape 的常用属性
- Android中shape的属性大全
- angular2 标签中attribute和property
- 22.从上往下打印二叉树
- 使用继承
- POJ-Is It A Tree?
- 打开网址出现HTTP 错误 500.21
- GradienDrawable可以改变xml中shape的属性
- java(C语言实验——时间间隔)
- 【数据分析】图书馆数据-07关联规则
- 完美解决Error:Connection timed out: connect. If you are behind an HTTP proxy, please configure the proxy
- 跟小博老师一起学JSP ——EL表达式
- 图像进行卷积运算来提取特征
- java 第三课
- 蓝桥杯algo1区间k大数查询
- db2 "create view" 缺乏权限