title: How to create image each time the user touch on screen
body: <p>There are two <code>ImageViews</code> in my <code>RelativeLayout</code>. I can move the image by touching and dragging it on anywhere on screen. 
  The images are in <code>drawable</code> folder</p>
  
  <p><strong>But now I want the followings:</strong> </p>
  
  <ol>
  <li>where ever the user touch on screen it should show another same
  image.  </li>
  <li>keep displaying image (without removing previous one) on dragging
  the image.</li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/XMYT6.png" rel="nofollow noreferrer">Sample Screenshot of what I want to do</a></p>
  
  <p>activity_main.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/relativeLayout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".MainActivity"&gt;
  
      &lt;ImageView
          android:id="@+id/backgroundIv"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_alignParentStart="true"
          android:layout_alignParentLeft="true"
          android:layout_alignParentTop="true"
          android:layout_alignParentEnd="true"
          android:layout_alignParentRight="true"
          android:layout_alignParentBottom="true"
          android:layout_centerInParent="true"
          android:scaleType="fitXY"
          android:src="@drawable/windows_xp_desktop" /&gt;
  
      &lt;ImageView
          android:id="@+id/foregroundIv"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerInParent="true"
          android:scaleType="fitXY"
          android:src="@drawable/win_xp_error" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Main Activity.java</p>
  
  <pre><code>package com.example.myapplication;
  
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.MotionEvent;
  import android.view.View;
  import android.view.ViewGroup;
  import android.view.Window;
  import android.view.WindowManager;
  import android.widget.ImageView;
  import android.widget.RelativeLayout;
  
  public class MainActivity extends AppCompatActivity {
  
      ImageView backgroundIv, foregroundIv;
      RelativeLayout relativeLayout;
  
      private ViewGroup rootLayout;
      private int xDelta;
      private int yDelta;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          //Hiding Title bar of this activity screen */
          getWindow().requestFeature(Window.FEATURE_NO_TITLE);
          //Making this activity, full screen */
          getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
          setContentView(R.layout.activity_main);
  
          backgroundIv = findViewById(R.id.backgroundIv);
          foregroundIv = findViewById(R.id.foregroundIv);
          relativeLayout = findViewById(R.id.relativeLayout);
  
          RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(350, 200);
          foregroundIv.setLayoutParams(layoutParams);
          foregroundIv.setOnTouchListener(new ChoiceTouchListener());
      }
  
      private class ChoiceTouchListener implements View.OnTouchListener {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
  
              final int X = (int) event.getRawX();
              final int Y = (int) event.getRawY();
  
  
              switch (event.getAction() &amp; MotionEvent.ACTION_MASK) {
  
                  case MotionEvent.ACTION_DOWN:
                      RelativeLayout.LayoutParams lParams = (RelativeLayout.LayoutParams) v.getLayoutParams();
                      xDelta = X - lParams.leftMargin;
                      yDelta = Y - lParams.topMargin;
                      break;
  
                  case MotionEvent.ACTION_UP:
                      break;
                  case MotionEvent.ACTION_POINTER_DOWN:
                      break;
                  case MotionEvent.ACTION_POINTER_UP:
                      break;
                  case MotionEvent.ACTION_MOVE:
                      RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) v.getLayoutParams();
                      layoutParams.leftMargin = X - xDelta;
                      layoutParams.topMargin = Y - yDelta;
                      layoutParams.rightMargin = -250;
                      layoutParams.bottomMargin = -250;
                      v.setLayoutParams(layoutParams);
                      break;
  
              }
              relativeLayout.invalidate();
              return true;
          }
      }
  
  }
  </code></pre>