Reputation: 16128
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!
Upvotes: 3
Views: 14045
Reputation: 304
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" >
Upvotes: 14
Reputation: 2927
Dear i can suggest you that try to Combine button text instead simple button.In Your code you try
android:background="@drawable/rad_background"
android:button=**"@null"**
Instead use my code and display combine button like this.
<Button
android:id="@+id/btnCrop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:background="@android:color/transparent"
android:drawableTop="@drawable/icon_crop_selector"
android:text="@string/btnCrop"
android:textAppearance="@style/TextButton"
android:textColor="#ffffff" />
This will be help to you.
Upvotes: 0
Reputation: 180
You can use textview :-
<TextView
android:id="@+id/home_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/rad_home"
android:layout_marginTop="10dp"
android:text="home" />
Upvotes: 0