Android Canvas plotting series (2)

Source: Internet
Author: User

Android Canvas plotting series (2)

The Paint brush is used here. Let's move and translate official documents.

 

1. setAlpha (int)

 

Sets the transparency. The parameter range is 0-255.

To change the attribute, we recommend that you change it to (0-1) and multiply it by 255.

 

2. setColor (int color)

Set the paint brush color to contain transparency. The parameter is 0xff777777 type. 0x is a hexadecimal identifier. The last two ff values indicate transparency, and the last six are color values.

 

3. setARGB (int a, int r, int g, int B)

Set the rgb color value and transparency;

The first parameter is transparency;

The second is the red color value;

The third is the green color value;

The fourth is the blue color value;

The range of parameters is 0-255;

 

4. setAntiAlias (boolean aa)

Note that the source code shows that this is a native method, and all this method will call the c ++ static library of the android system (so it may take a little more time)

If this parameter is set to true, it is set to remove the image's sawtooth effect. We recommend that you set this parameter to true. (If you look at the ps magic wand tool, you will know how disgusting the Sawtooth edges are ).

If you don't mind indicating a sawtooth effect, set it to false to speed up painting.

 

5. setTextSize (float textSize)

This is also a native method (Note: native method, jni calls the underlying C ++ implementation) and sets the font size. Here, px is not sp. If you want to set it in java code, it is recommended to convert it before setting it (search for android sp and convert it to px by yourself)

 

6. setStyle (Style style)

Set paint Style

The style parameter is an enumeration Style of Paint;

For example, setStyle (Paint. Style. FILL)

FILL is filled,

STROKE.

All FILL_AND_STROKE and above...

 

7. setStrokeWidth (float width)

Set the width of the paint brush when the style is STROKE or FILL_AND_STROKE.

 

Ps: the first four are commonly used.

 

 

 

 

 

Related Article

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.