1

I'm using this to crop an image and then i load it to this imageView:

        <RelativeLayout
            android:id="@+id/activity_edit_image_relative_layout_container"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true">

            <ImageView
                android:id="@+id/activity_edit_image_image"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="#ff2299"
                android:scaleType="fitCenter"
                android:src="@drawable/phone" />

        </RelativeLayout>

the color i'm giving to the background of the image view is pink ( so it will be easy to spot) and the relative layout will act as the view group and i will add other views to it at run time.

the pink background must only appear for the images that have transparent background (png files) like this (this picture is not cropped)

enter image description here

but when i crop an image and load it to the image view i get this

enter image description here enter image description here

the pink background must not appear. the issue is i'm trying to figure out where on the image is the user taping (overloading onTouch for the imageView) now when i tap on the pink area around the Alien it tells me that i'm tapping the image which is not correct. whats the issue?

Amir Heshmati
  • 550
  • 1
  • 8
  • 19

1 Answers1

2

Add the following property to your ImageView:

android:adjustViewBounds="true"
Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441