Reputation: 2378
In Android
, I want to use RadioButton
, but I do not want to check a plain text. How can I get the display in the first image instead of the second image? Using RadioGroup
and RadioButton
.
Upvotes: 4
Views: 5852
Reputation: 1811
Nothing special to do.. just add drawable in it like this:
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_launcher"/>
For an effect like this:
RadioButton
itself contains a TextView
as default.. so you can do all the operations those are present for any TextView
.
BONUS: If you want to change the circular dot that shows check
status, just update the android:button
tag to refer your own drawable
.
Upvotes: 10
Reputation: 1432
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/radio1"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_launcher"
/>
</RadioGroup>
this is the alteranative approch which i am using :-).
Upvotes: 3