Java 单选按钮没有正确对齐

Java 单选按钮没有正确对齐,java,android,eclipse,radio-button,radio-group,Java,Android,Eclipse,Radio Button,Radio Group,请看一下下面的代码 <ScrollView 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" tools:cont

请看一下下面的代码

    <ScrollView 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"
        tools:context=".Form" >

        <RelativeLayout 
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            >




            <TextView
               android:id="@+id/gender"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:text="Text To Be Displayed"
               android:layout_below="@+id/hipsTxt"
               /> 

            <RadioGroup 
                android:id="@+id/genderRadio"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                    android:layout_toRightOf="@+id/gender"
                    android:layout_alignBaseline="@+id/gender"
                >

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

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

            </RadioGroup>


        </RelativeLayout>

</ScrollView>

这里,我需要单选按钮显示在
TextView
的旁边。但是,它却显示在文本视图下方!!这里怎么了?请帮忙

PS:Android 2.3.3版取代

android:layout_alignBaseline="@+id/gender" android:layout_alignBaseline=“@+id/gender” 使用

android:layout\u alignParentTop=“true”代替

android:layout_alignBaseline="@+id/gender" android:layout_alignBaseline=“@+id/gender” 使用

android:layout\u alignParentTop=“true”试试这个:

<ScrollView 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"
    tools:context=".Form" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/gender"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"
            android:text="Text To Be Displayed" />

        <RadioGroup
            android:id="@+id/genderRadio"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="horizontal" >

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

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

</ScrollView>

试试这个:

<ScrollView 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"
    tools:context=".Form" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/gender"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"
            android:text="Text To Be Displayed" />

        <RadioGroup
            android:id="@+id/genderRadio"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="horizontal" >

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

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

</ScrollView>



尝试并更改了xml内容,现在它已正确对齐,请尝试使用此内容。




尝试并更改了您的xml内容,现在它已正确对齐,请尝试使用此内容。

谢谢您的帮助。我真的很感激:)谢谢你的帮助。我真的很感激:)谢谢你的回复。我真的很感激+谢谢你的回复。我真的很感激+谢谢你的回复。我真的很感激+谢谢你的回复。我真的很感激+我发了一封信:)
    <RelativeLayout 
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        > 

        <RadioGroup 
            android:id="@+id/genderRadio"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
                android:layout_toRightOf="@+id/gender"

            >

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

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

        </RadioGroup>

        <TextView
            android:id="@+id/gender"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:text="Text To Be Displayed" />

    </RelativeLayout>