title: How to drag and drop an image from a Recycler view and place it outside of it into another layout
body: <p>I have a horizontal Recylcer view which holds a list of items. Each item has a text view and image view to represent the item (e.g an image of a square and the text "Square" above the image). The recylcer view is inside of it's own 
  relative layout positioned at the top of the screen. What I need to do is drag an image from the recycler view and drop it outside of it into another layout that is below this one. However, the image that is dragged from the recycler view must not be removed, but instead a copy of the image should be placed into the outside layout. The image must also be dropped in the exact position in the layout where the user releases their finger. Is there any way to achieve this?</p>
  
  <p>An example of this could be like in a game, where the user has a list of objects to drag and drop into the game world.</p>
  
  <p>Here's an example to illustrate what I mean:</p>
  
  <p><img src="https://i.stack.imgur.com/ydz3C.png" alt="example"></p>
  
  <p>Adapter class for Recycler View:</p>
  
  <pre><code>public class RecyclerAdapter extends RecyclerView.Adapter&lt;RecyclerAdapter.ViewHolder&gt; {
  
  private List&lt;ListItems&gt; listItems;
  private Context context;
  
  public RecyclerAdapter(List&lt;ListItems&gt; listItems, Context context) {
      this.listItems = listItems;
      this.context = context;
  }
  
  @Override
  public RecyclerAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View v = LayoutInflater.from(parent.getContext())
              .inflate(R.layout.layout_recycler_view_row_one, parent, false);
  
      ViewHolder vh = new ViewHolder(v);
      return vh;
  }
  
  @Override
  public void onBindViewHolder(RecyclerAdapter.ViewHolder holder, int position) {
  
      ListItems listItems = listItems.get(position);
  
      holder.textView.setText(listItems.getItemName());
      holder.imageView.setImageResource(listItems.getImageDrawable());
  }
  
  
  @Override
  public int getItemCount() {
      return listItems.size();
  }
  
  public class ViewHolder extends RecyclerView.ViewHolder {
  
      public ImageView imageView;
      public TextView textView;
  
      public ViewHolder(View itemView) {
          super(itemView);
          imageView = (ImageView) itemView.findViewById(R.id.item_image_view);
          textView = (TextView) itemView.findViewById(R.id.item_name_text_view);
  
      }
  }
  </code></pre>
  
  <p>MainActivity.class:</p>
  
  <pre><code> public class MainActivity extends AppCompatActivity {
  
  RelativeLayout relativeLayoutMiddle;
  
  private RecyclerView recyclerView;
  private RecyclerView.LayoutManager layoutManager;
  private RecyclerView.Adapter adapter;
  private List&lt;ListItems&gt; listItems;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      listItems = new ArrayList&lt;&gt;();
  
      for (int i = 0; i &lt; 4; i++) {
          if(i==0)
          {
              ListItems listItems = new ListItems("Square", R.drawable.square);
              listItems.add(listItems);
          }
          else if(i==1)
          {
              ListItems listItems = new ListItems("Circle", R.drawable.circle);
              listItems.add(listItems);
          }
          else if(i==2)
          {
              ListItems listItems = new ListItems("Rectangle", R.drawable.rectangle);
              listItems.add(listItems);
          }
          else if(i==3)
          {
              ListItems listItems = new ListItems("Triangle", R.drawable.triangle);
              listItems.add(listItems);
          }
      }
  
      recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
      recyclerView.setHasFixedSize(true);
      layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
      recyclerView.setLayoutManager(layoutManager);
      adapter = new RecyclerAdapter(listItems, this);
      recyclerView.setAdapter(adapter);
  
      relativeLayoutMiddle = (RelativeLayout) findViewById(R.id.relativeLayoutMiddle);
  </code></pre>