EGHDK
EGHDK

Reputation: 18130

Two ImageViews with the same xml properties acting differently in Android Relative layout

I have two imageviews in a relative layout. One keeps acting almost 3 times the width as the other. Both pngs are 60px x 60px, so I don't understand why one is being drawn 3 times as wide. The image is not stretched, it just takes up 3 times more width in the relative layout.

The two imageviews:

<RelativeLayout
    android:id="@+id/linerlayout1"
    android:layout_width="wrap_content"
    android:layout_height="50dp"
    android:layout_above="@+id/container_ide"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:background="@drawable/gradient" >

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_weight="1"
        android:clickable="true"
        android:onClick="that"
        android:padding="6dp"
        android:src="@drawable/icon_image" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_weight="1"
        android:clickable="true"
        android:onClick="this"
        android:padding="6dp"
        android:src="@drawable/image_two" />

</RelativeLayout>

They should (In my knowledge) behave exactly the same. As you can see in the screenshot below @drawable/image_two is acting way off. The bounding box being three times too wide is killing my layout. Any ideas?

enter image description here

Upvotes: 0

Views: 216

Answers (1)

francisOpt
francisOpt

Reputation: 870

Your code works fine for me with different image.

So perhaps it is something to do with your image?

Upvotes: 2

Related Questions