原有的设置 在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"
/>