android的xml中怎么实现按钮按下去变颜色

得意犹堪夸世俗,诏黄新湿字如鸦。这篇文章主要讲述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中怎么实现按钮按下去变颜色】 


    推荐阅读