Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is no onTouchListener on path object.However, Follow the steps to achive this functionality</p> <p>1.) override onTouchEvent() method to Find the coordinates you have touched. This link may help. <a href="http://developer.android.com/training/graphics/opengl/touch.html" rel="nofollow noreferrer">http://developer.android.com/training/graphics/opengl/touch.html</a></p> <p>2.) create a RectF boundsRect and for each path object store its boundary coordinates by using </p> <pre><code>Path.getBounds(boundsRect); </code></pre> <p>method and simultaneously check whether the touch coordinates lie in the rectF boundsRect(using bounds.contains(x,y)) in a loop in the above method.</p> <p>3.)select that path and do desired operation on it now.</p> <p>Edited Code</p> <pre><code>@Override public boolean onTouch(View v,MotionEvent event){ switch(event.getAction()){ case MotionEvent.ACTION_DOWN: //screen touch get x of the touch event x = event.getX(); //screen touch get y of the touch event y = event.getY(); //check if touch point intersects the path bounds for (Path p : paths) { RectF pBounds = new RectF(); p.computeBounds(pBounds,true); if(pBounds.contains(x,y)){ //select path selected Path = p;// where selectedPath is assumed declared. break; } dv.invalidate(); break; case MotionEvent.ACTION_UP: //screen touch get x of the touch event x = event.getX(); //screen touch get y of the touch event y = event.getY(); break; case MotionEvent.ACTION_MOVE: //screen touch get x of the touch event x = event.getX(); //screen touch get y of the touch event y = event.getY(); break; } } return true; } </code></pre>
    singulars
    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.
    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