android - Position of view changes in on drag listner -
android - Position of view changes in on drag listner -
i placing views on parent layout. want drag entire view on long click of l1. when long click on l1, view enters in dragging mode changes position of touch center of view (x,y). want drag view holding upper bar of layout(l1).
view: ______________ |______l1______| | | y | l2 | | | |______________| x @override public boolean ondrag(view v, dragevent event) { // handles each of expected events switch (event.getaction()) { //signal start of drag , drop operation. case dragevent.action_drag_started: // nil break; //the drag point has entered bounding box of view case dragevent.action_drag_entered: v.setbackground(targetshape); //change shape of view break; //the user has moved drag shadow outside bounding box of view case dragevent.action_drag_exited: v.setbackground(normalshape); //change shape of view normal break; //drag shadow has been released,the drag point within bounding box of view case dragevent.action_drop: dostuff(); break; //the drag , drop operation has concluded. case dragevent.action_drag_ended: v.setbackground(normalshape); //go normal shape default: break; } homecoming true; }
you can set draging point in image using view.dragshadowbuilder
:
view.onprovideshadowmetrics(/* size of shadow */, /* provide point object x cordinate equal whole width of l1 , y cordinate equal height of l1*/);
this way can set shadow touch point l1
you can refer developer page dragshadowbuilder
android view drag-and-drop position touch
Comments
Post a Comment