bhavdip
bhavdip

Reputation: 189

how to change position of radio Button in radio group

how to create radio button group view in that button like horizontal in pic, i tried xml file but does found proper tag in that.... this is my xml file

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<RadioGroup
    android:id="@+id/radioGroup1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

    <RadioButton
        android:id="@+id/radio0"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:checked="true"
        android:text="RadioButton" />

    <RadioButton
        android:id="@+id/radio1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="RadioButton" />

    <RadioButton
        android:id="@+id/radio2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="RadioButton" />
</RadioGroup>

enter image description here

Upvotes: 1

Views: 3210

Answers (2)

Yatharth Agarwal
Yatharth Agarwal

Reputation: 4564

The Android Documentation for Radio Groups mentions that it inherits from Linear Layout. Searching for 'orientation' turns up the android:orientation property.

The default is horizontal.

Must be one of the following constant values.

Constant      Value   Description
horizontal    0       Defines an horizontal widget.
vertical      1       Defines a vertical widget.

This corresponds to the global attribute resource symbol orientation.

So simply add this property to Radio Group:

android:orientation="horizontal"

Upvotes: 1

Phant&#244;maxx
Phant&#244;maxx

Reputation: 38098

In your RadioGroup, set:

android:orientation="horizontal"

Because RadioGroup inherits from LinearLayout

Upvotes: 2

Related Questions