Android----Paint Touch track monitor

Source: Internet
Author: User

Paint Touch track monitoring, mainly three kinds of, action_down,action_move,action_up

 PublicBoolean ontouchevent (motioneventEvent){   intAction =Event. Getaction (); floatx =Event. GetX (); floaty =Event. GetY (); Switch(action) { CaseMotionEvent.ACTION_DOWN:mPath.moveTo (x, y);  Break;  CaseMotionEvent.ACTION_MOVE:mPath.quadTo (MPOSX, Mposy, x, y);  Break;  Casemotionevent.action_up://Mpath.reset ();     Break; }   //records the current coordinates of the current touch pointMPOSX =x; Mposy=y;return true;}

But the touch draw track has two effects, one is that the finger moves over, the trajectory appears, then set in the Action_up: in the action_up, draw the Cachecanvas.drawpath (path, paint);

 PublicBoolean ontouchevent (motioneventEvent) {        //TODO auto-generated Method Stub        floatx =Event. GetX (); floaty =Event. GetY (); Switch(Event. Getaction ()) {             Casemotionevent.action_down: {cur_x=x; Cur_y=y;                Path.moveto (cur_x, cur_y); Ismoving=true;  Break; }             CaseMotionevent.action_move: {if(!ismoving) Break; //Two-time curve drawingpath.quadto (cur_x, cur_y, x, y); //Cachecanvas.drawpath (path, paint); //The following method seems to be the same as above//Path.lineto (x, y);cur_x =x; Cur_y=y;  Break; }             Casemotionevent.action_up: {//The mouse bounces to save the last stateCachecanvas.drawpath (path, paint);                Path.reset (); Ismoving=false;  Break; }        }

The second is to show the drawing trajectory when touching, then set in Action_move: Cachecanvas.drawpath (path, paint);

 PublicBoolean ontouchevent (motioneventEvent) {        //TODO auto-generated Method Stub        floatx =Event. GetX (); floaty =Event. GetY (); Switch(Event. Getaction ()) {             Casemotionevent.action_down: {cur_x=x; Cur_y=y;                Path.moveto (cur_x, cur_y); Ismoving=true;  Break; }             CaseMotionevent.action_move: {if(!ismoving) Break; //Two-time curve drawingpath.quadto (cur_x, cur_y, x, y);                Cachecanvas.drawpath (path, paint); //The following method seems to be the same as above//Path.lineto (x, y);cur_x =x; Cur_y=y;  Break; }             Casemotionevent.action_up: {//The mouse bounces to save the last state//Cachecanvas.drawpath (path, paint);Path.reset (); Ismoving=false;  Break; }        }

Android----Paint Touch track monitor

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.