Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to disable right and left drag ImageView in Android?
    primarykey
    data
    text
    <p>in my application I want drag and Drop Imageview By touch in Screen.I could drag it on screen in Four Directions but I want just drag in top to Botton and disable right and left for drag Imageview.</p> <p>my code for drag-drop imageview in srceen:</p> <pre><code>public class MainActivity extends Activity implements OnTouchListener, OnDragListener { private static final String LOGCAT = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); findViewById(R.id.textView1).setOnTouchListener(this); findViewById(R.id.pinkLayout).setOnDragListener(this); findViewById(R.id.yellowLayout).setOnDragListener(this); } public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(view); view.startDrag(null, shadowBuilder, view, 0); view.setVisibility(View.INVISIBLE); return true; } else { return false; } } public boolean onDrag(View layoutview, DragEvent dragevent) { int action = dragevent.getAction(); switch (action) { case DragEvent.ACTION_DRAG_STARTED: Log.d(LOGCAT, "Drag event started"); break; case DragEvent.ACTION_DRAG_ENTERED: Log.d(LOGCAT, "Drag event entered into " + layoutview.toString()); break; case DragEvent.ACTION_DRAG_EXITED: Log.d(LOGCAT, "Drag event exited from " + layoutview.toString()); break; case DragEvent.ACTION_DROP: Log.d(LOGCAT, "Dropped"); View view = (View) dragevent.getLocalState(); ViewGroup owner = (ViewGroup) view.getParent(); owner.removeView(view); LinearLayout container = (LinearLayout) layoutview; container.addView(view); view.setVisibility(View.VISIBLE); break; case DragEvent.ACTION_DRAG_ENDED: Log.d(LOGCAT, "Drag ended"); break; default: break; } return true; } } </code></pre> <p>How to Resolve it? thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload