checkbox文字和复选框的间距设置

 原有的设置 在xml中          

             <CheckBox 
            android:id="@+id/login_remenber_pwd"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:button="@drawable/check_rond_selector"
            android:text="记住密码"
            android:textColor="@android:color/white"
            android:paddingLeft="5dip"
            />


但发现发现在4.1和4.2的手机上效果不一样,4.1上的文字和复选框重叠了,而4.2上的效果是正常的。原来是两个版本的paddingleft计算方法不一样,4.1中没有加上图标的宽度,4.2以后中计算时加上了图标的宽度。因此 有两种方法解决。

一  判断手机版本号来设置 (比较麻烦)

if(getAndroidSDKVersion()<=16){

 }

二 直接在xml文件中设置

          <CheckBox 
            android:id="@+id/login_remenber_pwd"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:button="@null"
            android:drawableLeft="@drawable/check_rond_selector"
            android:drawablePadding="5dip"

            android:text="记住密码"
            android:textColor="@android:color/white"
            android:paddingLeft="0dip"
            />

  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值