I need to make such a RadioButton and add them to the RadioGroup . Is it possible to create your own custom radiobutton with your own markup?
1 answer
Create in res\drawable something like this
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/rbutton_checked" android:state_checked="true"/> <item android:drawable="@drawable/rbutton_unchecked" android:state_checked="false"/> </selector> call it rbutton_selector.xml for example, and add it to your RadioButton in the main markup
<RadioButton ... android:button="@drawable/rbutton_selector" /> all that remains is to create a drawable/rbutton_checked and drawable/rbutton_unchecked for the selected and unselected state.
As for the option that you need, I can offer something like this:
<RadioGroup ... <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/<ваша картинка>" /> <RadioButton android:id="@+id/radioButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:button="@null" android:drawableBottom="?android:attr/listChoiceIndicatorSingle" android:text="Radio Button Text" /> </LinearLayout> ... </RadioGroup> Well, you have to add your logic to the collaboration of the switches, because RadioButton no longer the successor of RadioGroup and there will not be a single choice.
- android: background = "@ drawable / rbutton_selector" probably not? - McDaggen
- it is possible and so, then you need to specify
android:button="@android:color/transparent"- Serodv - it’s not exactly what you want, if you do
android:button="@drawable/rbutton_selector"then theradiobuttoncirclesradiobutton- Rasul A-s - Added option in response - Serodv
|
