Reputation: 824
When using a checkbox with extra drawable (besides the one used for the checkbox) using drawableLeft, the two drawables overlapp one another.
There is nothing special about the checkbox settings, here:
<CheckBox android:id="@+id/low_priority_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/low_priority"
android:textColor="@color/primary_text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:drawableLeft="@drawable/ic_primary_priority_flag_low_medium"/>
Actual result:
Expected result:
This problem occurs with compileSdkVersion 22 on devices with API <= 16
By the way, using drawableRight works as it should.
Is this a bug in the framework? Any workaround?
Upvotes: 4
Views: 676
Reputation: 1456
Add style (style="@android:style/Widget.Holo.Light.CompoundButton.CheckBox") for the checkbox, which can move the drawable to correct position. The only issue is the distance between drawable and text is bigger than normal case for devices with API <= 16.
One of my CheckBox xml is listed as the following:
<CheckBox
android:id="@+id/male_toilet_checkbox"
style="@android:style/Widget.Holo.Light.CompoundButton.CheckBox"
android:layout_width="wrap_content"
android:layout_height="28dp"
android:drawableLeft="@drawable/m"
android:drawableStart="@drawable/m"
android:text="@string/male_toilet"
android:textSize="14sp"
android:textColor="#ff6c51ff"
app:layout_constraintTop_toBottomOf="@+id/split_line1" />
Upvotes: 0