Android UI Development Topic (ii) Drawing basics

Source: Internet
Author: User
Tags final reset

In the interface design of the Android UI Development topic (i), we introduce the Android platform Resource usage and bitmap related classes, and then give you an example of how various classes are useful and attentive. Today we continue to understand the more important drawing classes in the Android.graphics package.

First, Android.graphics.Matrix

Some common methods about the transformation, scaling and other related operations of graphics are:

void reset ()//Reset a Matrix object.

void set (Matrix src)//Copy a source matrix, and the constructor method matrix (matrix SRC) of this class

Boolean isidentity ()//returns whether this matrix is defined (already meaningful)

void Setrotate (float degrees)//Specify an angle to rotate 0,0 coordinates

void Setrotate (float degrees, float px, float py)//Specify an angle to rotate px,py coordinates

void Setscale (float sx, float sy)//Zoom

void Setscale (float sx, float sy, float px, float py)//zoom in coordinate px,py

void Settranslate (float dx, float dy)//pan

void Setskew (float kx, Float KY, float px, float py)//tilt with coordinate px,py

void Setskew (float kx, float ky)//Tilt

Second, Android.graphics.NinePatch

Ninepatch is unique to the Android platform, a non-vector graphics natural drawing processing, can help the regular graphics in the stretch will not zoom, the example of the Android Development network prompts you for the toast display is the principle, while the SDK provides a tool named Draw 9- Patch, this tool can be used in reference to our published Draw 9-patch use method introduction article. Because this class provides high quality support for transparent scaling, the graphic format is PNG, and the file name is. 9.png suffix such as android123.9.png.

Third, Android.graphics.Paint

Paint class We can understand the definition of the attributes of brushes and brushes, the common methods used in this class are as follows:

void reset ()//Reset

void Setargb (int a, int r, int g, int b) or void setcolor (int color) is the color of the set Paint object

void Setantialias (Boolean AA)//is anti-aliasing and needs to be matched with a void setflags (Paint.anti_alias_flag) to help anti-aliasing make its edges smoother.

Shader Setshader (Shader Shader)//Set Shadow, the Shader class is a matrix object, and if NULL clears the shadow.

void SetStyle (Paint.style. Style)//set style, generally filled with fill, or stroke sag effect.

void Settextsize (float textsize)//Set Font size

void SetTextAlign (Paint.align Align)//text alignment

Typeface Settypeface (typeface typeface)//set font, through the typeface can load Android internal fonts, generally for the Chinese language, part of the ROM can be added to their own, such as Jache and so on

Whether the void Setunderlinetext (Boolean underlinetext)//is set to underline requires an apostrophe and void setflags (Paint.underline_text_flag) method.

Four, Android.graphics.Rect

Rect we can understand the rectangular region, similar to point, Rect class in addition to the description of a rectangular region, android123 hints can help us calculate whether the graph collision (including) relationship, for Android game development is more useful, Its main member contains contains three overloaded methods to determine the inclusion relationship

Boolean contains (int left, int. top, int right, int bottom)

Boolean contains (int x, int y)

Boolean contains (Rect R)

Five, Android.graphics.Region

Region in the Android platform to represent a region and rect is different, it represents an irregular appearance, can be ellipses, polygons and so on, and rect is just a rectangle. Similarly region Boolean contains (int x, int y) members can determine whether a point is within the region

VI. android.graphics.Typeface

The typeface class is to help describe a font object that, in TextView, uses the Settypeface method to develop a font for the output text that directly constructs the calling member create method to directly specify a font name and style, such as

Static typeface Create (typeface family, int style)

Static typeface Create (String familyname, int style)

The IsBold and Isitalic methods are used to determine whether bold or italic fonts are included.

Final Boolean isbold ()

Final Boolean isitalic ()

The method of creating this class also has resources from the APK or from a specific file path, and its specific method is

Static typeface Createfromasset (Assetmanager Mgr, String path)

Static typeface CreateFromFile (File path)

Static typeface CreateFromFile (String path)

About the Android platform graphics, images we have in the first two sections have been sorted out, next time we will talk about the next Ninepatch example application.

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.