How to draw image at center of Radio button

android

Solution

Not actiually making the image centered, but you could make it appear that way... You could modify the image to have blank space on the left and cut off immediately to the right of the image.

EDIT

I don't know if you've seen any of these, but you made me curious so I went looking and found several links that might be helpful towards your ultimate goal of tabs on the bottom:

Niko's Blog

SO Question Answer

Another SO Question Answer

Good Luck!

Edit 2

Ok, found it. You will have to extend a new class from RadioButton and override onDraw(), then create an attrs.xml file you need to put in res/values so the code can get at platform-defined attributes.

Specific code here

Problem

I was looking through the example posted in http://bakhtiyor.com/2009/10/iphonish-tabs/, actually here they have placed Radio button as replacement for Tabview. But the problem is, i am unable to set the image to the centre. Its always getting aligned to left. Here is the screenshot. I want my view should look like this but instead i want image to be in center. This is how my layout XML file looks ``` <?xml version="1.0" encoding="utf-8"?> <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:padding="20dip"/> <RadioGroup android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:checkedButton="@+id/allcontacts" android:gravity="center" android:id="@+id/contactgroup"> <RadioButton android:id="@+id/allcontacts" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical" android:background="@drawable/button_radio"/> <RadioButton android:id="@+id/categories" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:background="@drawable/button_radio" android:orientation="vertical" android:layout_gravity="center|right"/> <RadioButton android:id="@+id/favourites" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:orientation="vertical" android:layout_weight="1" android:background="@drawable/button_radio"/> </RadioGroup> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0" android:visibility="gone" /> </LinearLayout> </TabHost> ``` Please advice me UPDATED image after using Default tab widget Is it possible to customize like above radio button in default tabview.?

Original source

Related problems