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"
/>