eggham0518
eggham0518

Reputation: 151

How to put radio button on the editText

This is a gender check button.

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=""/>

Upvotes: 0

Views: 177

Answers (4)

Vivek Makwana
Vivek Makwana

Reputation: 168

if you need only underline below the RadioButton then there is no need to put it in edittext. just put the view as shown below,

 <View
    android:layout_width="100dp"
    android:layout_height="1dp"
    android:layout_marginTop="10dp"
    android:background="#ccc" />

Upvotes: 0

AskNilesh
AskNilesh

Reputation: 69689

Try this way

<?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>

OUTPUT

enter image description here

Upvotes: 4

VIISHRUT MAVANII
VIISHRUT MAVANII

Reputation: 12678

To achieve this type of UI takes Two Radio button horizontally. after take View set height according to bottom line height. and put it to vertically of both radio buttons.

Upvotes: 0

Gavin Wright
Gavin Wright

Reputation: 3212

It looks to me like you just want a line underneath your RadioGroup. Just use a View with a height of 1dp and a background color.

Upvotes: 0

Related Questions