首页 > 代码库 > 每日总结 - android设置背景颜色报错
每日总结 - android设置背景颜色报错
每天坚持总结,总会发生质变!
今天给radiobutton设置背景颜色报错,信息如下:
item> tag requires a ‘drawable‘ attribute or child tag defining a drawable
解决方法:
你不能将颜色选择器用在background上,应该使用drawable selector。
1 <selector xmlns:android="http://schemas.android.com/apk/res/android"> 2 <item android:state_checked="true"> 3 <shape> 4 <solid android:color="@color/orange"></solid> 5 </shape> 6 </item> 7 <item android:state_checked="false"> 8 <shape> 9 <solid android:color="@color/gray"></solid>10 </shape>11 </item>12 </selector>
每日总结 - android设置背景颜色报错
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。