如何在相对布局中嵌套布局或创建两个相对布局?

时间:2011-06-05 17:15:57

标签: android xml android-layout

运行此

时,模拟器会继续崩溃
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10px"
android:background="@drawable/words_background">
<ImageView
    android:layout_height="wrap_content"
    android:id="@+id/imageView1"
    android:src="@drawable/logo"
    android:paddingTop="5dp"
    android:layout_width="wrap_content"
    android:layout_alignParentTop="true" />
<TextView
    android:layout_height="wrap_content"
    android:gravity="right"
    android:textSize="20dp"
    android:layout_width="wrap_content"
    android:id="@+id/lettersQuestion"
    android:paddingLeft="5dp"
    android:typeface="normal"
    android:text="@string/question"
    android:textStyle="bold"
    android:layout_below="@+id/imageView1"
    android:layout_alignRight="@+id/imageView1"></TextView>
<TextView
    android:layout_height="wrap_content"
    android:gravity="right"
    android:textSize="20dp"
    android:layout_width="wrap_content"
    android:id="@+id/board_lettersQuestion"
    android:paddingLeft="5dp"
    android:typeface="normal"
    android:text="@string/question"
    android:textStyle="bold"
    android:layout_below="@+id/lettersQuestion"
    android:layout_alignLeft="@+id/lettersQuestion"
    android:layout_alignRight="@+id/lettersQuestion"
    android:paddingTop="20dp"></TextView>
<EditText
    android:id="@+id/letters"
    android:layout_height="wrap_content"
    android:layout_width="280dp"
    android:hint="@string/enter_letters"
    android:layout_below="@+id/imageView1" />
<EditText
    android:id="@+id/board_letters"
    android:layout_height="wrap_content"
    android:layout_width="280dp"
    android:hint="Enter Board Letters"
    android:layout_below="@+id/letters" />
<TextView
    android:id="@+id/moreText"
    android:text="@string/more"
    android:layout_alignLeft="@id/board_letters"
    android:layout_below="@id/board_letters"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textSize="15dp"
    android:typeface="normal"
    android:paddingLeft="5dp"
    android:textStyle="bold" />
<View
    android:background="#eee9e9"
    android:layout_width="fill_parent"
    android:layout_height="2dp"
    android:layout_centerVertical="true"
    android:layout_below="@id/moreText"
    android:paddingTop="3dp" />
<LinearLayout
    android:id="@+id/moreContent"
    android:visibility="gone">
<EditText
    android:layout_below="@+id/moreText"
    android:id="@+id/containsText"
    android:hint="Contains"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/moreText"
    android:layout_alignRight="@+id/moreText"
    android:paddingTop="5dp"></EditText>

<Spinner
    android:id="@+id/starts_with"
    android:entries="@array/alphabet_start"
    android:layout_width="155dp"
    android:hint="Starts With"
    android:layout_height="wrap_content"
    android:layout_below="@+id/editText1"
    android:layout_alignLeft="@+id/editText1"
    android:prompt="@string/starts_with"></Spinner>
<Spinner
    android:id="@+id/ends_with"
    android:entries="@array/alphabet_end"
    android:layout_width="155dp"
    android:prompt="@string/ends_with"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@+id/starts_with"
    android:layout_alignTop="@+id/starts_with"
    android:layout_alignBottom="@+id/starts_with"></Spinner>
<Spinner
    android:id="@+id/minSpinner"
    android:entries="@array/lengths_min"
    android:layout_width="80dp"
    android:prompt="@string/min_length"
    android:layout_height="wrap_content"
    android:layout_below="@id/starts_with"
    android:layout_alignLeft="@+id/starts_with"
    android:layout_alignRight="@+id/starts_with">
</Spinner>
<Spinner
    android:id="@+id/maxSpinner"
    android:entries="@array/lengths_max"
    android:layout_width="80dp"
    android:prompt="@string/max_length"
    android:layout_height="wrap_content"
    android:layout_below="@id/ends_with"
    android:layout_alignLeft="@id/ends_with"
    android:layout_alignRight="@id/ends_with"></Spinner>
</LinearLayout>
</RelativeLayout>

它工作正常如果我拿出LinearLayout可以有人请帮我格式化它运行正常。提前谢谢。

1 个答案:

答案 0 :(得分:1)

尝试向您的android:layout_width添加默认android:layout_heightandroid:orientationLinearLayout

编辑:此外,在LinearLayout上方的视图中添加ID。