Y
Y
Yuri Chorny2016-03-03 11:06:31
Android
Yuri Chorny, 2016-03-03 11:06:31

RadioButton, how to make a button to the right of the text?

Actually I'm trying to make a normal radioButton with a button to the right of the text, but it doesn't work. API 23.

<RadioGroup
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/radioGroup"
    android:layout_alignParentBottom="true"
    android:orientation="vertical"
    android:layout_gravity="end">
    <android.support.v7.widget.AppCompatRadioButton
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/radioButton1"
        android:gravity="right"
        android:text="sdf"/>
    <android.support.v7.widget.AppCompatRadioButton
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/radioButton2"
        android:gravity="right"
        android:text="sdfsdf"/>
    <android.support.v7.widget.AppCompatRadioButton
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/radioButton3"
        android:gravity="right"
        android:text="sdfsdf"/>
</RadioGroup>

android:gravity="right" doesn't help.
I read the advice to remove the standard button button="@null" and draw drawableRight="drawable/btn_radio"
on the right. But then Material Design is lost.
I tried to make a radioButton without text, press it to the right edge, and to the left make a textView. Looks ok, but only fires when the radioButton itself is clicked.
Is it possible to implement this without losing functionality/design?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lazard105, 2016-03-03
@Archdroid

You need to use style attributes. Like this :
The full description is like this:

<android.support.v7.widget.AppCompatRadioButton
        android:layout_width="match_parent"
        android:button="@null"
        android:drawableRight="?android:attr/listChoiceIndicatorSingle"
        android:layout_height="wrap_content"
        android:id="@+id/radioButton1"
        android:gravity="right"
        android:text="sdf"/>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question