android - i want to draw a simple line from one image to other where drag and drop the image -
this question same duplicate of https://stackoverflow.com/questions/11488357/android-drag-a-drawn-line-to-new-location-erasing-pixels-at-previous-locations
i'm using drag , drop , i'm making matching concept , drag image left right, when answer correct , @ there want draw line left right , use many things like
public class dragtesting extends activity implements ontouchlistener{ protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); this.requestwindowfeature(window.feature_no_title); this.getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); setcontentview(r.layout.drag); viewgroup dlayout = (viewgroup)findviewbyid(r.id.dlayout); dlayout.setontouchlistener(new ontouchlistener() { @override public boolean ontouch(view paramview, motionevent parammotionevent) { // todo auto-generated method stub if(touchflag==true){ switch (parammotionevent.getactionmasked()) { case motionevent.action_down : //getting positions break; case motionevent.action_up: break; canvas canvas = new canvas(); paint paint = new paint(); paint.setstyle(paint.style.stroke); paint.setstrokewidth(2); paint.setcolor(color.green); canvas.drawcolor(color.blue); canvas.drawline(offset_x, offset_y, currentx, currenty, paint); break; default: break; } } return true; } }); @override public boolean ontouch(view paramview, motionevent parammotionevent) { // todo auto-generated method stub switch (parammotionevent.getactionmasked()) { case motionevent.action_down: touchflag=true; offset_x = (int) parammotionevent.getx(); offset_y = (int) parammotionevent.gety(); // tagvalue = (integer) paramview.gettag(); selected_item = paramview; imageparams=paramview.getlayoutparams(); break; case motionevent.action_up: selected_item=null; touchflag=false; break; default: break; } return false; } this not working , me
i have extends relative layout , make design time view file, use draw line between image views , helps me, not right answer thats y m not accept other answer, m sory that
Comments
Post a Comment