title: OnTouch imageview creation being placed too low
body: <p>I have a custom floorplanView class within my main Activity. This custom view uses up roughly half the screen space. I am trying to simply create a star image and place it on the floor plan onTouch. However, for some reason this appears to place the image below where I am touching (I have tried a few variations and cannot work it out).</p>
  
  <pre><code> public class FloorplanView extends RelativeLayout {
  
      public FloorplanView(Context context, AttributeSet attrs) {
          super(context, attrs);
  
          SCROLL_THRESHOLD = getResources().getDimensionPixelSize(R.dimen.margin5);
          setClipChildren(false);
          setOnTouchListener(new FloorplanTouchListener());
      }
  
      public class FloorplanTouchListener implements View.OnTouchListener {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
              switch (event.getAction()) {
                  case MotionEvent.ACTION_DOWN:
                      posX = event.getRawX() - v.getX();
                      posY = event.getRawY() - v.getY();
                      break;
  
                  case MotionEvent.ACTION_UP:
                      ImageView img = new ImageView(getContext());
                      img.setOnTouchListener(new FlagTouchListener());
                      img.setBackground(getResources().getDrawable(android.R.drawable.btn_star));
                      img.setX(event.getRawX()); //Used posX/Y without success
                      img.setY(event.getRawY());
                      addView(img);
                      break;
              }
  
              return true;
          }
      }
  }
  </code></pre>
  
  <p>Further to this, is there a way to set bounds to my custom class with extends a relativeLayout so that when I drag and move my image (which is setup and working) it does not go outside of the Floorplanview custom class.</p>
  
  <p><strong>EDIT:</strong>
  The parent Activity class XML</p>
  
  <pre><code>&lt;RelativeLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      tools:context="com.fcs_systems.inspector.FloorplanActivity"&gt;
  
      &lt;TextView
          android:id="@+id/txtFloorplanName"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Floorplan Name"
          android:visibility="gone"/&gt;
  
      &lt;com.fcs_systems.inspector.FloorplanView
          android:id="@+id/floorplanView"
          android:background="@color/fcs_red"
          android:layout_width="match_parent"
          android:layout_height="200dp"/&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>