Android之自定义checkbox并解决内容和复选框之间的具体问题
2018-01-30 21:12
549 查看
1、问题
checkbox自定义并解决内容和复选框之间的具体问题2、代码实现
1、select_checkbox.xml文件<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/check_press5" android:state_checked="true"/>
<item android:drawable="@drawable/check_normal5" android:state_checked="false"/>
<item android:drawable="@drawable/check_normal5" />
</selector>
2、在styles.xml里面自定义样式
<style name="checkboxstyle" parent="@android:style/Widget.CompoundButton.CheckBox">
<item name="android:button">@drawable/selector_checkbox</item>
<item name="android:padding">10.0dip</item>
></style>注意这里的android:padding熟悉就可以把自定义图片和文字内容隔开了
3、一左一右使用
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingBottom="1dp"
>
<CheckBox
android:id="@+id/man"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="man"
style="@style/checkboxstyle"
/>
<CheckBox
android:id="@+id/woman"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="1dp"
android:text="woman"
style="@style/checkboxstyle"
/>
</RelativeLayout>
相关文章推荐
- android自定义CheckBox和RadioButton中文字和图片之间距离问题解决
- Android中不同Activity之间传递自定义对象的参数问题的解决
- android自定义listview,添加监听器,解决屏幕滑动组件状态干扰的问题checkbox
- 解决Android自定义CheckBox图片过大的问题
- 【完美解决系列】Android在自定义Dialog中TextView内容显示不全的问题
- Android 自定义listview 添加监听器 解决屏幕滑动组件状态干扰的问题checkbox
- android自定义listview,添加监听器,解决屏幕滑动组件状态干扰的问题checkbox ...
- Android 解决某些机型CheckBox自定义按钮图片时发生的错位问题
- 完美解决Android在listview添加checkbox实现单选多选操作问题
- 解决android自定义标题栏充满的问题
- 解决Android自定义多选ListView乱序问题
- Android 自定义CheckBoxPreference的CheckBox复选框
- 完美解决Android在listview添加checkbox实现批量操作问题
- android 自定义ScrollView实现反弹效果(以及解决和ListView之间的冲突)
- Android 自定义全局标题栏 解决输入法遮住屏幕问题
- Android 完美解决自定义preference与ActivityGroup UI更新的问题
- 解决android自定义标题栏充满的问题
- 完美解决Android在listview添加checkbox实现单选多选操作问题
- 解决Android在listview中checkbox批量操作问题
- 解决Android在listview添加checkbox实现单选多选操作问题