Reputation: 13
I'm creating custom checbox with this style
<item android:drawable="@drawable/bt_pick_true" android:state_checked="true"></item>
<item android:drawable="@drawable/bt_pick_false" android:state_checked="false"></item>
<item android:drawable="@drawable/bt_pick_true"></item>
I want to have text on that checbox to be over te this images, not on right side.
I try to add gravity on checkbox but nothing happend.
android:gravity="center_horizontal|center_vertical"
Upvotes: 1
Views: 1552
Reputation: 614
set it as background
<CheckBox
android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@null"
android:background="@drawable/cb_pick_style"
android:gravity="center_horizontal|center_vertical"
android:text="Text" />
Upvotes: 3
Reputation: 3633
Don't use android:button, use android:drawableLeft and give drawable_padding in negative. Like:
<CheckBox
android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@null"
android:drawableLeft="@drawable/ur custom_selector_checkbox"
android:drawablePadding="-20dp"
android:text="one" />
Upvotes: 0