I need a custom radio button with a custom background, centered text, an icon immediately before the text, but without the default indicator.
Currently, I have the following code:
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="@null"
android:background="@drawable/bg_rbtn_custom"
android:drawableLeft="@drawable/icon"
android:text="Lorem ipsum…" />
The problem is the icon defined in drawableLeft
, is pushed all the way to the left, i.e.
[icon]____Lorem ipsum…________
I need this:
____[icon]Lorem ipsum…________
The same thing happens when I use android:button="@drawable/icon
; the icon is place at the left-most part of the View
, and the text is then centred inside the left-over space (rather than being centred relative to the entire View
). I am Android API 8, so I can't use drawableStart
, so I need a way to duplicate its behaviour (at least I assume that's what it does). The text is dynamic, and will change at runtime, so I can't really hard code the padding.
My question is quite similar to this one, but that guy only needed a Button
, but I need a RadioButton
that'll work in a RadioGroup
.