I have a default image set as a src for an ImageView. Then i want to change this image. I do this:
ImageView imageView;
imageView = (ImageView)findViewById(R.id.imageView);
imageView.setImageResource(R.drawable.dude);
The result is that it only puts itself ontop of the old one, why could that be?
EDIT: added the xml-file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageButton
android:id="@+id/imageView"
android:layout_width="241dp"
android:layout_height="214dp"
android:layout_gravity="center_horizontal"
android:background="@drawable/car"
android:src="@drawable/car" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/button0"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="clickclick"
android:textSize="30sp" />
<Button
android:id="@+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="clickclick"
android:textSize="30sp" />
<Button
android:id="@+id/button2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="clickclick"
android:textSize="30sp" />
<Button
android:id="@+id/button3"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="clickclick"
android:textSize="30sp" />
<Button
android:id="@+id/button4"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="30sp" />
</LinearLayout>
<TextView
android:id="@+id/textViewGame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/instructionsGame"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
Change
ImageViewheight/width toWRAP_CONTENT and removeandroid:background="@drawable/car"from ImageButton background :