ImageView in RelativeView causes crash?
Whenever I create an ImageView in my XML the emulator crashes.
<?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">
<EditText
android:id="@+id/letters"
android:layout_width="275dp"
android:layout_height="wrap_content"
android:hint="@string/enter_letters" />
<TextView
android:id="@+id/moreText"
android:text="@string/more"
android:l开发者_运维知识库ayout_alignLeft="@id/letters"
android:layout_below="@id/letters"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="15dp"
android:typeface="normal"
android:paddingLeft="5dp"
android:textStyle="bold" />
<Spinner
android:id="@+id/maxSpinner"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_below="@id/letters"
android:layout_alignRight="@id/letters"
android:visibility="gone" />
<Spinner
android:id="@+id/minSpinner"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_below="@id/maxSpinner"
android:layout_alignRight="@id/letters"
android:visibility="gone" />
<TextView
android:id="@+id/lettersQuestion"
android:typeface="sans"
android:text="@string/question"
android:gravity="right"
android:textSize="20dp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentRight="true">
</TextView>
<ImageView
android:id="@+id/logo_image" />
</RelativeLayout>
You are missing the + in a few of your id references, and layout_alignRight will accept "true" or "false" only (you are probably looking for layout_ToRightOf)toTherightOf! AND an ImageView needs height and width set to something.
You should definitely look at your LogCat for the exact error,
but your XML should look like this
<RelativeLayout id="@+id/rel_layout">
<Spinner
android:id="@+id/maxSpinner"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/letters"
android:visibility="gone"/>
<Spinner
android:id="@+id/minSpinner"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_below="@+id/maxSpinner"
android:layout_toRightOf="@+id/letters"
android:visibility="gone"/>
<TextView
android:id="@+id/lettersQuestion"
android:typeface="sans"
android:text="@string/question"
android:gravity="right"
android:textSize="20dp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentRight="true"/>
<ImageView
android:id="@+id/logo_image"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
</RelativeLayout>
精彩评论