得意犹堪夸世俗,诏黄新湿字如鸦。这篇文章主要讲述android的xml中怎么实现按钮按下去变颜色相关的知识,希望能为你提供帮助。
//第一个例子
< ?xml version="1.0" encoding="utf-8"?> < selector xmlns:android="http://schemas.android.com/apk/res/android"> < item android:state_pressed="true" android:color="@color/baise"/> < item android:state_pressed="false" android:color="@color/heise"/> < /selector>
//第二个例子 < ?xml version="1.0" encoding="utf-8"?> < selector xmlns:android="http://schemas.android.com/apk/res/android"> < item android:state_pressed="true"> < shape android:shape="rectangle"> < solid android:color="@color/greencolor"/> < /shape> < /item> < /selector>
//第三个例子 < ?xml version="1.0" encoding="utf-8"?> < selector xmlns:android="http://schemas.android.com/apk/res/android"> < item android:state_pressed="true"> < shape android:shape="rectangle"> < solid android:color="@color/greencolor"/> < corners android:radius="8dp"/> < padding android:bottom="0dp" android:top="0dp"/> < /shape> < /item> < item android:state_pressed="false"> < shape android:shape="rectangle"> < solid android:color="@color/graycolor"/> < padding android:bottom="0dp" android:top="0dp"/> < corners android:radius="8dp"/> < /shape> < /item> < /selector>
【android的xml中怎么实现按钮按下去变颜色】
推荐阅读
- android中如何获取指定目录下的图片
- 解决错误:Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package.(示例
- android监听软键盘事件并获取键盘高度
- [Hyperapp] Interact with the State Object through Hyperapp Action functions
- 利用命令行删除Android系统自带应用的方法
- Android音视频深入十二FFmpeg视频替换声音(附源码下载)
- Android音视频深入十一FFmpeg和AudioTrack播放声音(附源码下载)
- monkey-获取app包名
- 如何让A20,android开机自动启动C程序