Raunak Pandey
Raunak Pandey

Reputation: 370

View not displaying inside RadioGroup

I want to get something like this

enter image description here

So I want a divider that divides the two radio buttons knowing the fact that Radio Group is a child class of Linear Layout with default oreintation set to vertical However If I do so. It is not happening. below is my tried xml code :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/bottomSheet"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingStart="20dp"
    android:paddingEnd="20dp"
    android:paddingTop="24dp"
    android:paddingBottom="16dp"
    android:background="@drawable/bottom_sheet_back"
    app:layout_behavior="@string/bottom_sheet_behavior">

    <TextView
        android:id="@+id/txtBottomNeft"
        .... />

    <ImageView
        android:id="@+id/imgBottomNeft"
        ... />

    <RadioGroup
        android:id="@+id/radioGroup"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/txtBottomNeft"
        android:layout_marginTop="32dp"
        android:orientation="vertical">

        <RadioButton
            android:id="@+id/radioIndian"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:fontFamily="@font/lato"
            android:text="Indian Citizen"
            android:textColor="#2B2E33"
            android:textSize="16sp" />

        <View
            android:layout_width="match_parent"
            android:layout_height="0.3dp"
            android:layout_marginTop="16dp"
            android:layout_marginBottom="14dp" />

        <RadioButton
            android:id="@+id/radioForeign"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:fontFamily="@font/lato"
            android:text="Foreign/Dual Passport Holder"
            android:textColor="#2B2E33"
            android:textSize="16sp" />
    </RadioGroup>
    
    <LinearLayout
        ...">

        <Button
            ..../>

        <Button
            ..../>
    </LinearLayout>
</RelativeLayout>

output of the above code:
enter image description here

Upvotes: 1

Views: 100

Answers (1)

Felix
Felix

Reputation: 292

You can just add a background color to your view between the buttons

<View
android:layout_width="match_parent"
android:layout_height="0.3dp"
android:background="@android:color/black"
android:layout_marginTop="16dp"
android:layout_marginBottom="14dp" />

To make it shorter add margin to the right and left. Here are also some other options.

Upvotes: 1

Related Questions