Выровнять текст под RadioButton

Мне нужно выровнять текст под RadioButton по этому тексту RadioButton, а не по значку RadioButton. Могу ли я получить его без использования жесткой маржи?

Пример: введите здесь описание изображения

Мой код ниже:

                    <LinearLayout
                        android:id="@+id/llcontainer"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_marginTop="@dimen/half_keyline"
                        android:orientation="horizontal">

                        <RadioButton
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            android:text="text1"/>

                    </LinearLayout>

person ksarkes    schedule 26.05.2016    source источник
comment
покажите нам свой файл макета, чтобы мы могли помочь вам наилучшим образом, какой родитель содержит переключатель, текст и т. д.   -  person Marko Niciforovic    schedule 26.05.2016
comment
это просто LinearLayout с RadioButton внутри   -  person ksarkes    schedule 26.05.2016
comment
Вы можете использовать пользовательскую кнопку (с известным размером) для галочки RadioButton. Затем используйте ту же ширину для левого поля TextView.   -  person    schedule 26.05.2016
comment
Стоит ли менять встроенное радио на свое? Я могу это сделать, но я думаю, что это не лучшее решение   -  person ksarkes    schedule 26.05.2016
comment
У вас есть идея получше?   -  person    schedule 26.05.2016
comment
Нет, поэтому я здесь, лол   -  person ksarkes    schedule 26.05.2016
comment
Используйте RelativeLayout и его атрибуты выравнивания.   -  person Nanoc    schedule 26.05.2016


Ответы (3)


Попробуй это

<LinearLayout
    android:id="@+id/llcontainer"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <RadioButton
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="text1"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="text2"
        android:layout_marginLeft="30dp"/>

</LinearLayout>
person Abanoub Samaan    schedule 26.05.2016

попробуй это

<RadioButton
     android:id="@+id/Icon1"
     android:layout_width="wrap_content"
     android:layout_height="match_parent"
     android:background="@android:color/transparent"
     android:button="@android:color/transparent"
     android:drawablePadding="-20dp"
     android:drawableTop="@drawable/your_Image_Here"
     android:gravity="center"
     android:text="text1" />
person Pavya    schedule 26.05.2016

Попробуй это:

                    <RadioButton
                        android:id="@+id/rbtn"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="text1"/>

                     <  TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:id="@+id/text1"
                        android:layout_below="@+id/rbtn" <!-- this here -->
                        android:text="@string/hello_world"/>
                </RelativeLayout>
person MurugananthamS    schedule 26.05.2016