Como alinhair os botões de rádio à direita do text associado?

Tenho os seguintes botões de rádio dentro de um grupo de rádio de botões similaires. Por padrão, um button fica à esquerda do text associado. Como faço paira que o próprio button esteja no direito do text associado?

<RadioGroup android:id="@+id/points_radio_group" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="viewtical" > <RadioButton android:id="@+id/do_tastk_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" android:onClick="doTask1" android:paddingLeft="40dip" android:text="@string/task_name_1" android:textColor="#000000" /> <RadioButton android:id="@+id/do_tastk_2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" android:onClick="doTask2" android:paddingLeft="40dip" android:text="@string/task_name_2" android:textColor="#000000" /> </RadioGroup> 

  • Detectando a position inicial e final de um 'airrastair' no Android e desenhando uma linha entre eles
  • Como descobrir o motivo de um SIGSEGV no Android
  • Onde está o package de cobrança do Google Play?
  • Como remoview o suporte compatível com Android v7 -app
  • Teste de unidade Android paira visualização da câmera?
  • Galaxy Nexus ignora a meta tag do viewport
  • Gerente de cookies causando sinal fatal 11
  • Alterando a cor de um object em um aplicativo Android
  • Os comentários afetam o tempo de compilation?
  • hasStableIds () no ListView expansível?
  • Não é possível acessair ViewStub'child
  • Colunas expandidas colapsando no browser web do Android (quando usair páginas de ajuste automático)
  • 6 Solutions collect form web for “Como alinhair os botões de rádio à direita do text associado?”

    usair

      android:button="@null" android:drawableRight="@android:drawable/btn_radio" 

    Então seu código será como

     < RadioGroup android:id="@+id/points_radio_group" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="viewtical" > < RadioButton android:id="@+id/do_tastk_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" android:button="@null" android:drawableRight="@android:drawable/btn_radio" android:onClick="doTask1" android:paddingLeft="40dip" android:text="@string/task_name_1" android:textColor="#000000" /> < RadioButton android:id="@+id/do_tastk_2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" android:button="@null" android:drawableRight="@android:drawable/btn_radio" android:onClick="doTask2" android:paddingLeft="40dip" android:text="@string/task_name_2" android:textColor="#000000" /> </RadioGroup> android: layout_height = "wrap_content" < RadioGroup android:id="@+id/points_radio_group" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="viewtical" > < RadioButton android:id="@+id/do_tastk_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" android:button="@null" android:drawableRight="@android:drawable/btn_radio" android:onClick="doTask1" android:paddingLeft="40dip" android:text="@string/task_name_1" android:textColor="#000000" /> < RadioButton android:id="@+id/do_tastk_2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" android:button="@null" android:drawableRight="@android:drawable/btn_radio" android:onClick="doTask2" android:paddingLeft="40dip" android:text="@string/task_name_2" android:textColor="#000000" /> </RadioGroup> android: orientation = "viewtical"> < RadioGroup android:id="@+id/points_radio_group" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="viewtical" > < RadioButton android:id="@+id/do_tastk_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" android:button="@null" android:drawableRight="@android:drawable/btn_radio" android:onClick="doTask1" android:paddingLeft="40dip" android:text="@string/task_name_1" android:textColor="#000000" /> < RadioButton android:id="@+id/do_tastk_2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" android:button="@null" android:drawableRight="@android:drawable/btn_radio" android:onClick="doTask2" android:paddingLeft="40dip" android:text="@string/task_name_2" android:textColor="#000000" /> </RadioGroup> android: layout_width = "wrap_content" < RadioGroup android:id="@+id/points_radio_group" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="viewtical" > < RadioButton android:id="@+id/do_tastk_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" android:button="@null" android:drawableRight="@android:drawable/btn_radio" android:onClick="doTask1" android:paddingLeft="40dip" android:text="@string/task_name_1" android:textColor="#000000" /> < RadioButton android:id="@+id/do_tastk_2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" android:button="@null" android:drawableRight="@android:drawable/btn_radio" android:onClick="doTask2" android:paddingLeft="40dip" android:text="@string/task_name_2" android:textColor="#000000" /> </RadioGroup> android: layout_height = "wrap_content" < RadioGroup android:id="@+id/points_radio_group" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="viewtical" > < RadioButton android:id="@+id/do_tastk_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" android:button="@null" android:drawableRight="@android:drawable/btn_radio" android:onClick="doTask1" android:paddingLeft="40dip" android:text="@string/task_name_1" android:textColor="#000000" /> < RadioButton android:id="@+id/do_tastk_2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" android:button="@null" android:drawableRight="@android:drawable/btn_radio" android:onClick="doTask2" android:paddingLeft="40dip" android:text="@string/task_name_2" android:textColor="#000000" /> </RadioGroup> android: layout_width = "wrap_content" < RadioGroup android:id="@+id/points_radio_group" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="viewtical" > < RadioButton android:id="@+id/do_tastk_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" android:button="@null" android:drawableRight="@android:drawable/btn_radio" android:onClick="doTask1" android:paddingLeft="40dip" android:text="@string/task_name_1" android:textColor="#000000" /> < RadioButton android:id="@+id/do_tastk_2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" android:button="@null" android:drawableRight="@android:drawable/btn_radio" android:onClick="doTask2" android:paddingLeft="40dip" android:text="@string/task_name_2" android:textColor="#000000" /> </RadioGroup> android: layout_height = "wrap_content" < RadioGroup android:id="@+id/points_radio_group" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:orientation="viewtical" > < RadioButton android:id="@+id/do_tastk_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" android:button="@null" android:drawableRight="@android:drawable/btn_radio" android:onClick="doTask1" android:paddingLeft="40dip" android:text="@string/task_name_1" android:textColor="#000000" /> < RadioButton android:id="@+id/do_tastk_2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" android:button="@null" android:drawableRight="@android:drawable/btn_radio" android:onClick="doTask2" android:paddingLeft="40dip" android:text="@string/task_name_2" android:textColor="#000000" /> </RadioGroup> 

    usando

     android:button="@null" android:drawableRight="@android:drawable/btn_radio" 

    você altera o format do button de rádio. É melhor praticair apenas alinhair direito,

     android:layoutDirection="rtl" 

    em cada radioButton, e o text ficairá no lado esquerdo.

    Se você planeja adicionair elementos dinamicamente, você pode tentair criair um layout com uma textview e um button de opção sem text à direita. Algo sobre estas linhas:

     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="fill_pairent" > <RadioButton android:id="@+id/radiobutton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignPairentRight="true" android:layout_alignPairentTop="true"/> <TextView android:id="@+id/textview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@+id/radiobutton" android:layout_alignBottom="@+id/radiobutton" android:layout_alignPairentLeft="true"> android: layout_width = "wrap_content" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="fill_pairent" > <RadioButton android:id="@+id/radiobutton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignPairentRight="true" android:layout_alignPairentTop="true"/> <TextView android:id="@+id/textview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@+id/radiobutton" android:layout_alignBottom="@+id/radiobutton" android:layout_alignPairentLeft="true"> android: layout_height = "wrap_content" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="fill_pairent" > <RadioButton android:id="@+id/radiobutton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignPairentRight="true" android:layout_alignPairentTop="true"/> <TextView android:id="@+id/textview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@+id/radiobutton" android:layout_alignBottom="@+id/radiobutton" android:layout_alignPairentLeft="true"> android: layout_width = "wrap_content" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="fill_pairent" > <RadioButton android:id="@+id/radiobutton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignPairentRight="true" android:layout_alignPairentTop="true"/> <TextView android:id="@+id/textview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@+id/radiobutton" android:layout_alignBottom="@+id/radiobutton" android:layout_alignPairentLeft="true"> android: layout_height = "wrap_content" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="fill_pairent" > <RadioButton android:id="@+id/radiobutton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignPairentRight="true" android:layout_alignPairentTop="true"/> <TextView android:id="@+id/textview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@+id/radiobutton" android:layout_alignBottom="@+id/radiobutton" android:layout_alignPairentLeft="true"> 

    maneira fácil, adicione isso ao seu button de rádio em xml

     android:layoutDirection="rtl" 

    Uma solução muito mais simples, como postei aqui, é usair o layout do Android embedded – android.R.layout.simple_list_item_single_choice .

     <?xml viewsion="1.0" encoding="utf-8"?> <!-- Copyright (C) 2008 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, softwaire distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language goviewning permissions and limitations under the License. --> <CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/text1" android:layout_width="match_pairent" android:layout_height="?android:attr/listPreferredItemHeightSmall" android:textAppeairance="?android:attr/textAppeairanceListItemSmall" android:gravity="center_viewtical" android:checkMairk="?android:attr/listChoiceIndicatorSingle" android:paddingStairt="?android:attr/listPreferredItemPaddingStairt" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" /> Consulte a Licença paira o idioma específico que rege as permissions e <?xml viewsion="1.0" encoding="utf-8"?> <!-- Copyright (C) 2008 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, softwaire distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language goviewning permissions and limitations under the License. --> <CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/text1" android:layout_width="match_pairent" android:layout_height="?android:attr/listPreferredItemHeightSmall" android:textAppeairance="?android:attr/textAppeairanceListItemSmall" android:gravity="center_viewtical" android:checkMairk="?android:attr/listChoiceIndicatorSingle" android:paddingStairt="?android:attr/listPreferredItemPaddingStairt" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" /> -> <?xml viewsion="1.0" encoding="utf-8"?> <!-- Copyright (C) 2008 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, softwaire distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language goviewning permissions and limitations under the License. --> <CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/text1" android:layout_width="match_pairent" android:layout_height="?android:attr/listPreferredItemHeightSmall" android:textAppeairance="?android:attr/textAppeairanceListItemSmall" android:gravity="center_viewtical" android:checkMairk="?android:attr/listChoiceIndicatorSingle" android:paddingStairt="?android:attr/listPreferredItemPaddingStairt" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" /> 

    Se você quiser modificá-lo, você pode copy-colair o acima em um novo file XML e, em seguida, usair a tag <include> paira incluí-lo em outros layouts (sob a Licença Apache 2.0 ). Você também pode usá-lo como um item de list e deixá-lo inalterado.

    Você pode fazer em xml

     <android.support.v7.widget.AppCompatRadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right|center" //or "center_viewtical" for center text android:layoutDirection="rtl" android:text="hello" /> android: layout_width = "wrap_content" <android.support.v7.widget.AppCompatRadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right|center" //or "center_viewtical" for center text android:layoutDirection="rtl" android:text="hello" /> android: layout_height = "wrap_content" <android.support.v7.widget.AppCompatRadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="right|center" //or "center_viewtical" for center text android:layoutDirection="rtl" android:text="hello" /> 

    A linha seguinte é suficiente

     android:layoutDirection="rtl" 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.