Android 自定义CheckBox RadioButton中的button,且设置与文字的间距
来源:互联网 发布:js 插件写法 编辑:程序博客网 时间:2024/05/16 01:42
一般的方法都是
<CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:button="@drawable/radio_btn_selector" android:paddingLeft="5dp" android:text="@string/setting" />
但是在4.1.2(API 16)以下的系统显示会有问题,字和图片会重叠
(原因是之前的版本中CompoundButton没有getCompoundPaddingLeft,之后的版本绘制文字时,会把图片的宽度和paddingLeft的宽度加上,而老版本只计算设置的paddingLeft
参考http://blog.csdn.net/danielinbiti/article/details/39049631)
解决重叠换了一种实现方式,采用android:drawableLeft <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:button="@null" android:drawableLeft="@drawable/radio_btn_selector" android:drawablePadding="5dp" android:text="@string/setting" />
重叠问题解决了,但是在4.1.2(API 16)以下的系统显示会有问题,左边空出一块,默认的button虽然设为null不显示但还是会占位
设置属性
android:paddingLeft="0dp"
这样就可以正确显示了,同时适配了所有版本
只能说好坑啊
0 0
- Android 自定义CheckBox RadioButton中的button,且设置与文字的间距
- android CheckBox RadioButton 图片与文字间距问题
- android CheckBox RadioButton 图片与文字间距问题
- CheckBox与文字的间距
- CheckBox与文字的间距
- CheckBox与文字的间距
- android RadioButton 图片与文字间距问题
- 如何减少RadioButton与文字的间距?
- Android Button图片和文字都居左,且有一点间距
- Android Button图片和文字都居左,且有一点间距
- radiobutton 选择框和文字间距的设置方法
- Android 自定义RadioButton 实现文字上下左右方向的图片大小设置
- Android 自定义RadioButton 实现文字上下左右方向的图片大小设置
- Android 自定义RadioButton 实现文字上下左右方向的图片大小设置
- android中checkbox文字和复选框的间距设置问题
- checkbox文字和复选框的间距设置
- Android控件之Button,RadioButton,CheckBox,DatePicker,DatePickerDialog的使用
- radiobutton的文本方位及与图片间距设置
- IOS开发限制UITextField只可以输入数字
- Android汉字转拼音HanziToPinyin
- GenomicRangeQuery
- 全世界第三,全中国第一! 【黑商】【小李木耳】出品:黑土地中的稀缺极品:千年黑土!
- Swift协议 (待继续学习)
- Android 自定义CheckBox RadioButton中的button,且设置与文字的间距
- iOS 视图被覆盖时怎么接受事件处理
- adb常用命令
- CentOS下MySQL数据库的安装
- Linux PPTP连接VPN客户端
- 浅谈struts2
- echart 图表显示技术
- unity脚本执行顺序详解
- Android编程之LayoutInflater的inflate方法详解及其中参数的作用