简体   繁体   中英

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?

在此输入图像描述

Your code works fine for me with different image.

So perhaps it is something to do with your image?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM