Jorge Gil
Jorge Gil

Reputation: 2865

App crashes when adding an ImageView

This is my xml. The imageview1 works fine, the problem comes when i add the second imageview. I did a little research and found something about the problem having to do with the @id+/ but i didnt really understood. Can someones tell what's wrong?

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

<Button
    android:id="@+id/button3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:enabled="false"
    android:text="@string/next"
    android:textSize="30sp" />

<Button
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_toLeftOf="@+id/button3"
    android:enabled="false"
    android:text="@string/check"
    android:textSize="30sp" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/button3"
    android:text="@string/mensaje"
    android:textSize="35sp" />

<TextView
    android:id="@+id/textView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/textView2"
    android:layout_marginTop="135dp"
    android:gravity="center"
    android:text="@string/pais"
    android:textSize="35sp" />

<EditText
    android:id="@+id/editText1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView1"
    android:layout_centerHorizontal="true"
    android:ems="10"
    android:inputType="text" >

    <requestFocus />
</EditText>

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="200dp"
    android:layout_height="100dp"
    android:layout_below="@+id/textView2"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="20dp"
    android:src="@drawable/canada" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/button2"
    android:layout_alignBottom="@+id/button2"
    android:layout_alignParentLeft="true"
    android:text="TextView"
    android:textSize="25sp" />

<ImageView
    android:id="@+id/imageView2"
    android:layout_width="40dp"
    android:layout_height="40dp"
    android:layout_alignTop="@+id/editText1"
    android:layout_toRightOf="@+id/editText1"
    android:src="@drawable/paloma" />

</RelativeLayout>

Upvotes: 0

Views: 123

Answers (2)

Gowtham Raj
Gowtham Raj

Reputation: 2955

replace the RelativeLayout with

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

there can be only one xmlns attribute there are two in your code

Upvotes: 1

hichris123
hichris123

Reputation: 10223

You don't have an end tag for your RelativeLayout. Just put this at the bottom:

</RelativeLayout>

Also, have you made sure that the drawable that you're putting on the ImageView exists?

Upvotes: 2

Related Questions