写数字安全密码的时候,用到了shape,画了一个白色圆点,在点击数字键盘时,改变对应圆点背景为选中色
1、shape文件
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <!-- 边缘线的宽度和颜色 --> <corners android:bottomLeftRadius="10dp" android:bottomRightRadius="10dp" android:topLeftRadius="10dp" android:topRightRadius="10dp" /> <solid android:color="@color/white" /> <stroke android:width="1dp" android:color="@color/silver" /> </shape>
2、Activity相应监听事件中修改 solid对应的颜色
GradientDrawable gdOne = (GradientDrawable)view.getBackground();
gdOne.setColor(getResources().getColor(R.color.white));
最后
以上就是小巧小霸王最近收集整理的关于Android篇-更改shape背景颜色的全部内容,更多相关Android篇-更改shape背景颜色内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复