Как поставить радиокнопку на editText - PullRequest
0 голосов
/ 14 марта 2019

Это кнопка проверки пола.

I want to deploy like this

<EditText
      android:id="@+id/txtSex"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginRight="29dp"
      android:layout_weight="1"
      android:ems="10"
      android:inputType="textPersonName"
      android:text=""/>

Ответы [ 4 ]

4 голосов
/ 14 марта 2019

Попробуйте следующим образом

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="horizontal">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Select Gender" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="10dp"
        android:orientation="vertical">

        <RadioGroup
            android:layout_width="250dp"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="horizontal">

            <RadioButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="5dp"
                android:text="Male" />

            <RadioButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="5dp"
                android:text="Female" />

        </RadioGroup>

        <View
            android:layout_width="250dp"
            android:layout_height="2dp"
            android:background="@android:color/black" />

    </LinearLayout>
</LinearLayout>

ВЫХОД

enter image description here

2 голосов
/ 14 марта 2019

если вам нужно только подчеркнуть подчеркивание ниже RadioButton, тогда нет необходимости помещать его в текст редактирования. просто поместите вид, как показано ниже,

 <View
    android:layout_width="100dp"
    android:layout_height="1dp"
    android:layout_marginTop="10dp"
    android:background="#ccc" />
0 голосов
/ 14 марта 2019

Для достижения такого типа пользовательского интерфейса требуется две радиокнопки по горизонтали. после взятия Просмотр установленной высоты в соответствии с высотой нижней линии. и положите его вертикально на обе радиокнопки.

0 голосов
/ 14 марта 2019

Мне кажется, что вы просто хотите создать линию под своей радиогруппой.Просто используйте View с высотой 1dp и цветом фона.

...