How can i add radio buttons in android app with option as an image , not the text.. we can set the text to radio button by android:setText property. But i want an image to be displayed there and not the text.. Please help me?
We will use radio buttons to select the image that we want to see from the image slider by giving an unique id to each radio button. Next, we will embed all the images one by one and create labels for radio button id's and will apply necessary CSS properties to achieve the desired output.
To label a radio button, add a <label> element after the <input> element and insert a for attribute with the same value as the id of the associated <input> element. Then, write your label text in the <label> tag.
How about this one using the property android:drawableRight
?
<RadioGroup android:id="@+id/maptype" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/line1" android:orientation="horizontal" > <RadioButton android:id="@+id/map" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" android:drawableRight="@drawable/map" /> <RadioButton android:id="@+id/satellite" android:layout_width="wrap_content" android:layout_height="wrap_content" android:drawableRight="@drawable/sat" /> </RadioGroup>
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