I need your help to solve my layout problem.. I have 4 RadioButtons, they appear as usual in this scheme:
O text1 O text2 &nbs
Simpler solution with default RadioButton:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/radio7"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tvDays7"
android:text="7 looong days"
android:layout_centerHorizontal="true"
android:layout_below="@id/radio7"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
This is the solution to set the Text below RadioButtons:
This code android:drawablePadding="-20dp"
is not needed.
You add your own selector drawable here: android:drawableTop="@drawable/your_Image_Here".
<RadioGroup
android:id="@+id/RadioGroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/Icon1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:button="@android:color/transparent"
android:checked="true"
android:drawablePadding="-20dp"
android:drawableTop="@drawable/your_Image_Here"
android:gravity="center"
android:text="@string/your_Text_Here"
android:textColor="@color/icons_color" />
<RadioButton
android:id="@+id/Icon2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:button="@android:color/transparent"
android:drawablePadding="-20dp"
android:drawableTop="@drawable/your_Image_Here"
android:gravity="center"
android:text="@string/your_Text_Here"
android:textColor="@color/icons_color" />
</RadioGroup>
I don't think the plain RadioButton widget can do that by default. You'll need to do one of a few things to achieve that effect. You can create your own RadioButton view class by combining a RadioButton and a TextView so that you have complete control over where the items are in relation to each other. Or you can skip making it a view and just use two elements in your layout, 1 TextView and one RadioButton(with no text set to it).