-3

how can we arrange radio group's button as we want.. i don't want to arrange horizontally or vertically.. i want 2 radio buttons in a row and other two radio buttons in next row.. please help thank you in advance...

        <LinearLayout
            android:id="@+id/tt5"
            android:layout_width="fill_parent"
            android:layout_height="160dp"
            android:layout_marginTop="165dp"
            android:background="#fff" >
            <ImageView
                android:id="@+id/imageView7"
                android:layout_width="25dp"
                android:layout_height="25dp"
                android:layout_marginLeft="3dp"
                android:layout_marginTop="3dp"
                android:src="@drawable/icongender" />
            <RadioGroup
                android:id="@+id/radiogrp"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical" >

                <RadioButton
                    android:id="@+id/student"
                    android:layout_width="wrap_content"
                    android:layout_height="40dp"
                    android:background="@drawable/edittext"
                    android:checked="true"
                    android:paddingLeft="10dp"
                    android:text="\t\tStudent"
                    android:textColor="#616161" />

                <RadioButton
                    android:id="@+id/buisness"
                    android:layout_width="wrap_content"
                    android:layout_height="40dp"
                    android:paddingLeft="10dp"
                    android:background="@drawable/edittext"
                    android:text="\t\tBuisness"
                    android:textColor="#616161" />

                <RadioButton
                    android:id="@+id/entertainment"
                    android:layout_width="wrap_content"
                    android:layout_height="40dp"
                    android:paddingLeft="10dp"
                    android:background="@drawable/edittext"
                    android:text="\t\tEntertainment"
                    android:textColor="#616161" />

                <RadioButton
                    android:id="@+id/others"
                    android:layout_width="wrap_content"
                    android:layout_height="40dp"
                    android:paddingLeft="10dp"
                    android:background="@drawable/edittext"
                    android:text="\t\tOthers"
                    android:textColor="#616161" />

            </RadioGroup>
        </LinearLayout>

my xml code is above.. this shows me 4 radio buttons in one column but i want 2 radio buttons in one row and other two in next row. please help thank you in advance

Manav Patadia
  • 848
  • 7
  • 12

2 Answers2

1

You can simply make each two RadioButtons in one LinearLayoutwhich has an Horizontalorientation. Or you can use GridLayout.

Fouad Wahabi
  • 804
  • 7
  • 16
0

You would have to find a way to have the RadioGroup work with a custom layout. With these keywords you should be able to find more info.

This question seems to be what you are looking for: Android: custom layout for Radio Group

Community
  • 1
  • 1
Distwo
  • 11,569
  • 8
  • 42
  • 65