0

次のコードをご覧ください

    <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

4

3 に答える 3

1

それ以外の

android:layout_alignBaseline = "@ + id / agent"

使用する

android:layout_alignParentTop = "true"
于 2013-01-22T17:50:02.943 に答える
1

これを試して :

<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>
于 2013-01-22T17:51:03.087 に答える
1
<?xml version="1.0" encoding="utf-8"?>

    <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>

xmlコンテンツを試して変更しましたが、適切に配置されたので、これを試してください。

于 2013-01-22T17:54:16.210 に答える