3

次の RelativeLayout があります。

<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:orientation="horizontal" >

<RadioGroup
    <!--stuff-->
</RadioGroup>

<Spinner
android:id="@+id/colour_spinner"
android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:layout_below="@+id/radioGroup1" />

 <TextView
    android:id="@+id/colourLabel"
    android:text="@string/label_colour"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/radioGroup1"
    android:layout_toLeftOf="@+id/colour_spinner"/>

<Spinner
android:id="@+id/country_spinner"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:layout_below="@+id/colour_spinner" />

<TextView
    android:id="@+id/countryLabel"
    android:text="@string/label_country"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/colour_spinner"
    android:layout_toLeftOf="@+id/country_spinner"/>

<Spinner
    android:id="@+id/stadium_spinner"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:layout_below="@+id/country_spinner" />

<TextView
    android:id="@+id/stadiumLabel"
    android:text="@string/label_stadium"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/country_spinner"
    android:layout_toLeftOf="@+id/stadium_spinner"/>

うまくいけば、私がここでやろうとしていることは明らかです。3 つのスピナーがそれぞれ前のスピナーの下にあり、それぞれの左側にラベルがあり、理想的にはすべてがきちんと並んでいます。

私が現時点で得ている結果は、スピナーのみが画面に表示され、テキスト ラベルがまったく表示されないことです。ここで何が間違っていますか?レイアウトの幅/高さの設定に関係していると思われますか?

4

2 に答える 2

6

各スピナーとラベルを水平 LinearLayout 内に囲みます。

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

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

    <!-- stuff -->
</RadioGroup>

<LinearLayout
    android:id="@+id/spinner1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/radioGroup"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/colourLabel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/label_colour" />

    <Spinner
        android:id="@+id/colour_spinner"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1" />
</LinearLayout>

<LinearLayout
    android:id="@+id/spinner2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/spinner1"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/countryLabel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/label_country" />

    <Spinner
        android:id="@+id/country_spinner"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1" />
</LinearLayout>

<LinearLayout
    android:id="@+id/spinner3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/spinner2"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/stadiumLabel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/label_stadium" />

    <Spinner
        android:id="@+id/stadium_spinner"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1" />

</LinearLayout>

</RelativeLayout>
于 2013-03-02T03:38:54.237 に答える
0

これを試して:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >

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

    <TextView
        android:id="@+id/colourLabel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/radioGroup1"
        android:text="label_colour"
        android:textColor="@android:color/white" />

    <Spinner
        android:id="@+id/colour_spinner"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/radioGroup1"
        android:layout_toRightOf="@+id/colourLabel" />

    <TextView
        android:id="@+id/countryLabel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/colour_spinner"
        android:text="label_country"
        android:textColor="@android:color/white" />

    <Spinner
        android:id="@+id/country_spinner"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/colour_spinner"
        android:layout_toRightOf="@+id/countryLabel" />

    <TextView
        android:id="@+id/stadiumLabel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/country_spinner"
        android:text="label_stadium" />

    <Spinner
        android:id="@+id/stadium_spinner"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/country_spinner"
        android:layout_toRightOf="@+id/stadiumLabel" />

</RelativeLayout>
于 2013-03-02T03:38:47.890 に答える