title: How to implement image region click listener for multiple screen size in android?
body: <p>I want to create fullscreen activity that load image ad in fullscreen. The example image is like this:</p>
  
  <p><img src="https://i.stack.imgur.com/mblY4.png" alt="enter image description here"></p>
  
  <p>Note that, the button is also part of image. Here is the layout xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical" android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@drawable/ad_image"&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>You can see the image is loaded with <code>android:background</code>.</p>
  
  <p>What I want to achieve is: when the "Button" image portion is clicked, it will do something (like launching another activity), as well as the "Close [X]" rectangle at top-right corner, when clicked, it will close the activity.</p>
  
  <p>It seems it's easy to implement click logic on the region part of "Button" drawing. So far I found two ways:</p>
  
  <ol>
  <li><p>Set ontouch listener on LinearLayout and check it's X and Y coordinate for the Button drawing region</p></li>
  <li><p>Put invisible <code>ImageView</code> on top of "Button" image in layout, and set onclick listener.</p></li>
  </ol>
  
  <p>But the problem is: there are multiple screen sizes and resolutions across many android devices. So I wonder if those two solusions can be used in portable way across different screen size?</p>
  
  <p>Since the image might be stretched when loaded in different screen resolution, and that means for solution #1: I have to adjust X &amp; Y number. And for solution #2: the invisible ImageView's position might get synched-off from the Button drawing.</p>
  
  <p>So anyone know better solution for this?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I'm trying to use invisible click placeholder solution. Here is the layout xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical" android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@drawable/ad_image"
      android:id="@+id/adLayout"
      android:weightSum="1"&gt;
  
      &lt;LinearLayout
          android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_weight="0.75"/&gt;
  
      &lt;LinearLayout
          android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_weight="0.16"
          android:id="@+id/adImageLayout"
          android:onClick="adImageClicked"&gt;
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:orientation="vertical"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_weight="1"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><code>adImageLayout</code> is the click placeholder for the button drawing.</p>