title: Android: How to click button inside frame layout after zooming
body: <p>I am building my first android project/first java project. I am trying to draw an image with multiple buttons over the top of it that the user can click on. However after zooming in the button enlarges as i had hoped and maintains its relative position with the image in the background, but it no longer responds to the onClickListener. </p>
  
  <p>XML Code
          </p>
  
  <pre><code>&lt;FrameLayout
      android:id="@+id/DeckLayout"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:clickable="true"
      android:gravity="center_horizontal" &gt;
  
      &lt;!-- &lt;CustomDrawableView android:layout_height="fill_parent"
                 android:layout_width="fill_parent"
                /&gt;  --&gt;
  
      &lt;ImageView
          android:id="@+id/imageView1"
          android:layout_width="match_parent"
          android:layout_height="420dp"
          android:clickable="false"
          android:scaleType="fitCenter"
          android:src="@drawable/deck12" /&gt;
  
      &lt;Button
          android:id="@+id/QM2_12002"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:clickable="true"
          android:gravity="center"/&gt;
  
  
  &lt;/FrameLayout&gt;
  &lt;FrameLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:gravity="center_horizontal" &gt;
      &lt;Button
              android:id="@+id/zoom_in"
              android:layout_width="102dp"
              android:layout_height="wrap_content"
              android:gravity="center"
              android:text="@string/zoom_in" /&gt;
  &lt;/FrameLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Java Code</p>
  
  <pre><code>package com.sgs.hotelguru;
  
  import android.app.Activity;
  import android.content.Context;
  import android.content.Intent;
  import android.graphics.PointF;
  import android.os.Bundle;
  import android.support.v4.app.Fragment;
  import android.support.v4.app.FragmentActivity;
  import android.support.v4.app.FragmentManager;
  import android.support.v4.app.FragmentPagerAdapter;
  import android.support.v4.app.NavUtils;
  import android.support.v4.view.ViewPager;
  import android.util.Log;
  import android.view.Gravity;
  import android.view.LayoutInflater;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.MotionEvent;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.view.View.OnTouchListener;
  import android.view.ViewGroup;
  import android.widget.Button;
  import android.widget.TextView;
  import android.widget.Toast;
  
  
  
  
  public class MapsExample extends Activity {
  
      View mainView = null;
      final float Zoom_max = 5f;
      private static final String TAG = "Die Karte";
  
       @Override
       public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_maps_example);
        mainView =findViewById(R.id.DeckLayout);
  
        //Button buttonZoomOut = (Button)findViewById(R.id.zoom_out);
        //Button buttonNormal = (Button)findViewById(R.id.reset);
        Button buttonZoomIn = (Button)findViewById(R.id.zoom_in);
  
        /*buttonZoomOut.setOnClickListener(new OnClickListener() {
  
         @Override
         public void onClick(View v) {
          zoom(0.5f,0.5f,new PointF(0,0));    
         }
        });
        buttonNormal.setOnClickListener(new OnClickListener() {
  
         @Override
         public void onClick(View v) {
          zoom(1f,1f,new PointF(0,0));  
         }
        });*/
        buttonZoomIn.setOnClickListener(new OnClickListener() {
  
         @Override
         public void onClick(View v) {
          zoom(new PointF(0,0));   
         }
        });
        mainView.post(new Runnable() {
            // Post in the parent's message queue to make sure the parent
            // lays out its children before you call getHitRect()
            @Override
            public void run() {
                // The bounds for the delegate view (an ImageButton
                // in this example)
                Button QM2_12002 = (Button)findViewById(R.id.QM2_12002);
                QM2_12002.setX(300);
                QM2_12002.setY(400);
                QM2_12002.setEnabled(true);
                QM2_12002.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        Toast.makeText(MapsExample.this, 
                                "YOU CLICKY THE BUTTON YAY!", 
                                Toast.LENGTH_SHORT).show();
                    }
                });
  
            }
        });
    }
  
  
       /** zooming is done from here */
       public void zoom(PointF pivot){
        mainView.setPivotX(pivot.x);
        mainView.setPivotY(pivot.y);  
        float workScaleX = mainView.getScaleX();
        float workScaleY = mainView.getScaleY();
        if(workScaleX&lt;Zoom_max)
        {
        mainView.setScaleX(workScaleX+1f);
        mainView.setScaleY(workScaleY+1f);  
        }
       }
  
      }
  </code></pre>