title: Android view go invisible after drag
body: <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      img=(ImageView)findViewById(R.id.imageView);
  
      img.setOnLongClickListener(new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {
              ClipData.Item item = new ClipData.Item((CharSequence)v.getTag());
              String[] mimeTypes = {ClipDescription.MIMETYPE_TEXT_PLAIN};
  
              ClipData dragData = new ClipData(v.getTag().toString(),mimeTypes, item);
              View.DragShadowBuilder myShadow = new View.DragShadowBuilder(img);
  
              v.startDrag(dragData,myShadow,null,0);
              return true;
          }
      });
  
      img.setOnDragListener(new View.OnDragListener() {
          @Override
          public boolean onDrag(View v, DragEvent event) {
              switch(event.getAction()){            
                  case DragEvent.ACTION_DRAG_STARTED:
                      layoutParams = (RelativeLayout.LayoutParams)v.getLayoutParams();
                      break;
  
                  case DragEvent.ACTION_DRAG_ENTERED:
                      int x_cord = (int) event.getX();
                      int y_cord = (int) event.getY();
                      break;
  
                  case DragEvent.ACTION_DRAG_EXITED :
                      x_cord = (int) event.getX();
                      y_cord = (int) event.getY();
                      layoutParams.leftMargin = x_cord;
                      layoutParams.topMargin = y_cord;
                      v.setLayoutParams(layoutParams);
                      break;
  
                  case DragEvent.ACTION_DRAG_LOCATION  :
                      x_cord = (int) event.getX();
                      y_cord = (int) event.getY();
                      break;
  
                  case DragEvent.ACTION_DRAG_ENDED   :
                      break;
  
                  case DragEvent.ACTION_DROP:
                      break;
                  default: break;
              }
              return true;
          }
      });
  
      img.setOnTouchListener(new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
              if (event.getAction() == MotionEvent.ACTION_DOWN) {
                  ClipData data = ClipData.newPlainText("", "");
                  View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(img);
  
                  img.startDrag(data, shadowBuilder, img, 0);
                  img.setVisibility(View.INVISIBLE);
                  return true;
              } else  {
                  return false;
               }
           }
      });
   }
  }
  </code></pre>
  
  <p>This is my code (actually taken from somewhere else); here am trying to drag one image from one location to another location. But after dragging the image it disappeared from the screen.</p>
  
  <p>What I need is I want to drag an image view from one location to any location and it should be visible after dropping it in that new location and the new location coordinates will be saved in variables.
  When I close and relaunch the application, the image should be at new coordinates which are saved in my previous drag and drop operation</p>
  
  <p>If I set the visibility in onTouch event from INVISIBLE to VISIBLE, When I remove my finger after drag and drop operation the image still remains in same original position but not at the new location.</p>