Display text at the bottom of RadioButton with image in Android

android, radio-button

Solution

Try this:

<RadioButton
    android:id="@+id/radioMarch"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:drawableTop="@drawable/your_drawable_selector"
    android:gravity="center"
    android:button="@android:color/transparent"
    android:text = "text3"
/>

Problem

I'm using a customized radio button. Each element of radiogroup have 2 pics, for the 2 states, defined in the android:button attribute. I would like to add text, but it displays under the images, is there a way to display the text in the bottom of the image??? main_activity.xml ``` <RadioButton android:id="@+id/radioAlc" android:layout_width="50dp" android:layout_height="wrap_content" android:checked="true" android:layout_marginRight="10dp" android:button="@drawable/policeradio" android:text = "text1" /> <RadioButton android:id="@+id/radioCrash" android:layout_width="50dp" android:layout_height="wrap_content" android:button="@drawable/carcrashradio" android:layout_marginRight="10dp" android:text = "text2" /> <RadioButton android:id="@+id/radioMarch" android:layout_width="50dp" android:layout_height="wrap_content" android:button="@drawable/marchradio" android:text = "text3" /> </RadioGroup> ``` drawable/carcrash.xml ``` <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/carcrash" android:state_checked="true"></item> <item android:drawable="@drawable/carcrash_gris" ></item> ```

Original source