Android--Custom View Mini demo, about the use of the path Class (i)

Source: Internet
Author: User

1, when we know that the OnDraw () method in Custom view is used for drawing graphics, and the path class is one of the important classes, such as effects:

There's no difficulty in code, just post it.

@Override    protected void OnDraw (canvas canvas) {        canvas.drawcolor (color.white);        Paint paint = new paint ();        Paint.setantialias (true);        Paint.setcolor (0xffff6600);        Paint.settextsize (+);        Paint.setstyle (Paint.Style.STROKE);        Draw around the circular text        path PATH = new Path ();        Add clockwise circular path        path.addcircle (200,200,100, Path.Direction.CW);        Paint.setstyle (Paint.Style.FILL);        Canvas.drawtextonpath ("The Moonlight in front of the bed, suspected to be ground frost." Jutou looked at the moon, bowed his head and thought of home. ", path,0,-18,paint);    }

Draw the triangle as follows:

The code is as follows:

       Canvas.drawcolor (color.white);        Paint paint = new paint ();        Paint.setantialias (true);        Paint.setcolor (0xffff6600);        Paint.settextsize (+);        Paint.setstyle (Paint.Style.STROKE);        Draw the triangle path, path path        = new Path ();        Set the starting point of the curve        Path.moveto (+);        Sets the end point of the first edge        Path.lineto (+);        Set the end point of the second edge        Path.lineto (+);        Closed path        path.close ();        Paint.setcolor (color.red);        Canvas.drawpath (path, paint);

  

Draw a polyline

The code is as follows:

Path PATH = new Path ();        Path.moveto (a);        Path.lineto (250,200);        Path.lineto (300,250);        Path.lineto (350,400);        Path.lineto (400,310);        Path.lineto (500,100);        Canvas.drawpath (path, paint);

  

Android--Custom View Mini demo, about the use of the path Class (i)

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.