Skip to content Skip to sidebar Skip to footer

Radio Button With Image As An Option Instead Of Text

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 displ

Solution 1:

How about this one using the property android:drawableRight?

<RadioGroupandroid:id="@+id/maptype"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/line1"android:orientation="horizontal" ><RadioButtonandroid:id="@+id/map"android:layout_width="wrap_content"android:layout_height="wrap_content"android:checked="true"android:drawableRight="@drawable/map" /><RadioButtonandroid:id="@+id/satellite"android:layout_width="wrap_content"android:layout_height="wrap_content"android:drawableRight="@drawable/sat" /></RadioGroup>

Solution 2:

use this:

<RadioGroupandroid:id="@+id/radioGroup1"android:layout_width="wrap_content"android:layout_height="wrap_content" ><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="horizontal" ><RadioButtonandroid:id="@+id/radio0"android:layout_width="wrap_content"android:layout_height="wrap_content"android:checked="true" /><ImageViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:src="@drawable/ic_launcher" /></LinearLayout><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="horizontal" ><RadioButtonandroid:id="@+id/radio01"android:layout_width="wrap_content"android:layout_height="wrap_content"android:checked="true" /><ImageViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:src="@drawable/ic_launcher" /></LinearLayout><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="horizontal" ><RadioButtonandroid:id="@+id/radio02"android:layout_width="wrap_content"android:layout_height="wrap_content"android:checked="true" /><ImageViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:src="@drawable/ic_launcher" /></LinearLayout></RadioGroup>

Post a Comment for "Radio Button With Image As An Option Instead Of Text"