Android Canvas Drawing series (ii)

Source: Internet
Author: User

This is mainly about paint brushes. Transfer and translate the official documents.


1.setAlpha (int a)


Set the transparency, the parameter range is 0-255.

If you need to set the properties: the proposed change to (0-1), and then multiplied by 255.


2.setColor (int color)

Set the brush color which contains the transparency, the parameter is the 0xff777777 type, the 0x is the 16 binary identifier, the latter two FF is the transparency, the latter six is the color value


3.setARGB (int A, int r, int g, int b)

Set RGB color values and transparency;

The first parameter is transparency;

The second one is the red color value;

The third one is green value;

The fourth one is the blue color value;

The parameters range are 0-255;


4.setAntiAlias (Boolean AA)

Note that the source know that this is a native method, all this method will call the Android system C + + static library, (so it may take more time)

If the parameter is true, it is set to remove the plot jagged effect, and the recommended setting is true. (See the PS Wand tool cutout to know how disgusting the jagged edges are.)

If you don't mind the jagged effect, set to false to speed up drawing.


5. Settextsize (float textSize)

This is also a native method (note: Native native method, JNI calls the underlying C + + implementation), set the font size. Here is the PX is not the SP, if it is to be set in the Java code, it is recommended to set the conversion (self-search Android SP to px)


6. SetStyle (Style style)

Set Brush style

The style parameter is the enumeration type of paint style;

Use method such as: SetStyle (Paint.Style.FILL)

Fill is filled,

Stroke strokes.

Fill_and_stroke above all have ...


7.setStrokeWidth (float width)

Sets the width of the brush when the style is a stroke or a fill_and_stroke.


PS: The first 4 are commonly used.






Android Canvas Drawing series (ii)

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.