Android中自定义Checkbox
16lz
2021-01-23
custom_checkbox.xml文件:
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/btn_unselect" android:state_checked="false"/> <item android:drawable="@drawable/btn_select" android:state_checked="true"/></selector>
styles.xml中
<style name="custom_checkbox" parent="@android:style/Widget.CompoundButton.CheckBox"> <item name="android:button">@drawable/custom_checkbox</item> </style>
Checkbox:
<CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" android:text="全(不)选" android:layout_margin="10dip" android:paddingLeft="10dip" android:textSize="20sp" style="@style/custom_checkbox" android:textColor="@color/black"/>
备注:
paddingLeft为左边的图标与右边的文字之间的距离
更多相关文章
- Android Q : 安卓源码、水滴屏适配状态栏图标(图标过多时显示一个
- Android权限问题 及 APP应用图标
- Android 系列 5.9使用Inkscape创建Android Launcher图标
- Android获取RecyclerView滑动距离
- SystemUI9.0系统应用图标加载流程
- Android百度地图SDK—地图标记
- android中求区域内两个坐标之间的距离的实现
- android editText 软键盘enter键图标的设置
- react-native APP图标和Splash(Android)