您的位置:首页 > 其它

Button背景颜色和背景图片

2018-03-23 12:00 260 查看
需要在drawable建xml文件  

在这里都需要在你的Button里引用一下android:background="@drawable/bjs"这个是背景颜色
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/colorAccent" android:state_checked="true">

</item>
<item android:drawable="@color/colorPrimaryDark">

</item>
</selector>这个是背景图片 
背景图片也是默认显示一个点击过后显示另一个  
你有几个按钮需要设置不同的图片
你有几种不同的图片就要建几个不同的xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/s1" android:state_checked="true"></item>
<item android:drawable="@drawable/s"></item>
</selector>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: