<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/hui" android:state_checked="true"/>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/hui" android:state_checked="true"/>
</selector>
这是设置点击到的背景颜色。如果把drawable换成了color将会闪退。设置点击后字体变色才用color
XML点击效果配置
本文介绍了一种使用XML配置文件来设定按钮或其他UI元素点击时背景颜色变化的方法。文章详细解释了如何通过设置android:drawable属性来实现点击效果,并强调了在使用不同属性时可能遇到的问题。
350

被折叠的 条评论
为什么被折叠?



