I need your help to solve my layout problem.. I have 4 RadioButtons, they appear as usual in this scheme:
O text1 O text2 O text3 O text4
where O is the button.. I would know if it's possible to change this layout in this way:
O O O O
text1 text2 text3 text4
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With