title: Coordinates of content of ImageView
body: <p>So I have an ImageView where I set png as a background. Let's assume the png picture is a circle, so it doesn't take all the space of the ImageView.
  I need to catch the event of clicking only the content of the ImageView (the circle) and not the remaining empty area.
  Is this actually possible at all or with any other Android control?</p>
  
  <p>Edit:
  I still can't get this to work.
  So to be more precise I have this picture of an egg which I set as ImageView src</p>
  
  <p><a href="https://i.stack.imgur.com/Zygu2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Zygu2.png" alt="enter image description here"></a> </p>
  
  <p>And I want to be able to click only on it. Foe example if I click slightly outside the egg I want to know that and prevent code inside the ImageView click event.</p>
  
  <p>I tried this code but I don't have any idea how this helps me:</p>
  
  <pre><code>ImageView imageView = (ImageView)findViewById(R.id.imageview);
  Drawable drawable = imageView.getDrawable();
  Rect imageBounds = drawable.getBounds();
  
  //original height and width of the bitmap
  int intrinsicHeight = drawable.getIntrinsicHeight();
  int intrinsicWidth = drawable.getIntrinsicWidth();
  
  //height and width of the visible (scaled) image
  int scaledHeight = imageBounds.height();
  int scaledWidth = imageBounds.width();
  
  //Find the ratio of the original image to the scaled image
  //Should normally be equal unless a disproportionate scaling
  //(e.g. fitXY) is used.
  float heightRatio = intrinsicHeight / scaledHeight;
  float widthRatio = intrinsicWidth / scaledWidth;
  
  //do whatever magic to get your touch point
  //MotionEvent event;
  
  //get the distance from the left and top of the image bounds
  int scaledImageOffsetX = event.getX() - imageBounds.left;
  int scaledImageOffsetY = event.getY() - imageBounds.top;
  
  //scale these distances according to the ratio of your scaling
  //For example, if the original image is 1.5x the size of the scaled
  //image, and your offset is (10, 20), your original image offset
  //values should be (15, 30). 
  int originalImageOffsetX = scaledImageOffsetX * widthRatio;
  int originalImageOffsetY = scaledImageOffsetY * heightRatio;
  </code></pre>