android RadioButton image and text

android, radio-button, xml

Solution

Try this: use drawableTop to show the icon

 <RadioButton
    android:id="@+id/rad_home"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:background="@drawable/rad_background"
    android:button="@null"
    android:drawableTop="@drawable/home_icon"
    android:gravity="center"
    android:text="Home"
    android:textColor="@drawable/text_background"
    android:textSize="@dimen/rad_text_size" >

Problem

Im using a radio button to create a custom tab host, is working fine, but now I need to show the icon on top and the text underneath the icon, this is what I have now: but this is what I need: This is my code: ``` <RadioButton android:id="@+id/rad_home" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:background="@drawable/rad_background" android:button="@drawable/home_icon" android:gravity="center" android:text="Home" android:textColor="@drawable/text_background" android:textSize="@dimen/rad_text_size" > </RadioButton> <RadioButton android:id="@+id/rad_1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:background="@drawable/rad_background" android:button="@null" android:gravity="center" android:text="Menu" android:textColor="@drawable/text_background" android:textSize="@dimen/rad_text_size" /> <RadioButton android:id="@+id/rad_2" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:background="@drawable/rad_background" android:button="@null" android:gravity="center" android:text="VIP" android:textColor="@drawable/text_background" android:textSize="@dimen/rad_text_size" /> <RadioButton android:id="@+id/rad_3" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:background="@drawable/rad_background" android:button="@null" android:gravity="center" android:text="About" android:textColor="@drawable/text_background" android:textSize="@dimen/rad_text_size" /> <RadioButton android:id="@+id/rad_4" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:background="@drawable/rad_background" android:button="@null" android:gravity="center" android:text="Whats On" android:textColor="@drawable/text_background" android:textSize="@dimen/rad_text_size" /> </RadioGroup> ``` So im setting the button icon with: android:button="@null" for when is empty and android:button="@drawable/home_icon" for the icon image, should I use this to set the icon? how to organize it as I need it? [icon on top, text bottom] I tried with a layout inside , but doesnt seem to like it? how to accomplish this? thanks!

Original source

Related problems