Hello I want to create RadioGroup that consists of 21 button, but they cant be in one line or column, there should be like 7x3. The problem is that i tried it without RadioGroup and it was fine. I used this xml code

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/darbu_pusl"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".DisplayJobsPage" >

<RadioButton
    android:id="@+id/radioButton1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="17dp"
    android:layout_marginTop="330dp"
    android:background="@drawable/job_btn_pi"
    android:gravity="left" />

<RadioButton
    android:id="@+id/radioButton2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/radioButton1"
    android:layout_marginLeft="23dp"
    android:layout_toRightOf="@+id/radioButton1"
    android:background="@drawable/job_btn_a"
    android:gravity="left" />

But now that i try using RadioGroup like this:

<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/darbu_pusl"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".DisplayJobsPage">
<RadioButton
    android:id="@+id/radioButton1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="17dp"
    android:layout_marginTop="330dp"
    android:background="@drawable/job_btn_pi"
    android:gravity="left" />

<RadioButton
    android:id="@+id/radioButton2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/radioButton1"
    android:layout_marginLeft="23dp"
    android:layout_toRightOf="@+id/radioButton1"
    android:background="@drawable/job_btn_a"
    android:gravity="left" />

I am getting warnings that layout_alignTop and layout_toRightOf is invalid layout parameters. Can you guys help me to figure this out? Is it posible to dublicate first layout options in RadioGroup?

有帮助吗?

解决方案

Wrap your RelativeLayout that works within a RadioGroup

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top