美文网首页
记录:CheckBox 自定义drawable

记录:CheckBox 自定义drawable

作者: _汉堡_ | 来源:发表于2020-04-07 10:20 被阅读0次

drawable目录下新建selector

<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:drawable="@drawable/checkbox_p" android:state_checked="true"/>

<item android:drawable="@drawable/checkbox_n" android:state_checked="false"/>

</selector>

style 里面声明一下selector

<style name="checkbox_selector" parent="@android:style/Widget.CompoundButton.CheckBox">

<item name="android:button">@drawable/checkbox_selector</item>

</style>

使用

<CheckBox

    android:id="@+id/checkbox"

    style="@style/checkbox_selector"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"/>

相关文章

网友评论

      本文标题:记录:CheckBox 自定义drawable

      本文链接:https://www.haomeiwen.com/subject/xwvvuxtx.html