Android UI development Topic (ii) Basics of plotting

Source: Internet
Author: User
Today, we will continue to introduce the content of the underlying plotting class of the Android platform. In the interface design of the android UI development topic (I), we will introduce operations on the Android platform resources and bitmap related classes, in the following example, we will show you the usage and attention of each type. Today, we continue to learn about the most important plotting classes in the Android. graphics package. 1. Android. Graphics. Matrix
Commonly used methods for image conversion, scaling, and other operations include:
Void reset () // reset a matrix object.
Void set (matrix SRC) // copy a source matrix, which is the same as the construction method matrix (matrix SRC) of this class.
Boolean isidentity () // returns whether the matrix is defined (meaningful)
Void setrotate (float degrees) // specify an angle to rotate with the coordinates of 0, 0.
Void setrotate (float degrees, float PX, float Py) // specify an angle to rotate with PX and Py coordinates
Void setscale (float Sx, float Sy) // scale
Void setscale (float Sx, float Sy, float PX, float Py) // scale with coordinates PX and Py
Void settranslate (float dx, float Dy) // Translation
Void setskew (float kx, float Ky, float PX, float Py) // tilt with coordinates PX and Py
Void setskew (float kx, float KY) // skew
2. Android. Graphics. ninepatch
Ninepatch is a natural stretch processing method unique to the Android platform for non-vector images. It can help regular images not scale during stretching, the android Development Network in the instance prompts you that this principle is the display of toast, and the SDK provides a tool named draw 9-patch, for how to use this tool, refer to the article draw 9-patch in our released release. This category features a high-quality and transparent scale-out format. The format is PNG, and the file name is .9.png with a suffix such as android123.9.png.
3. Android. Graphics. Paint
The paint class can be understood as the attribute definition of the paint brush and paint brush. The common methods of this class are as follows:
Void reset () // Reset
Void setargb (int A, int R, int g, int B) or void setcolor (INT color) are used to set the color of the paint object.
Void setantialias (Boolean aa) // whether the image is anti-aliasing. You need to use void setflags (paint. anti_alias_flag) to help remove the image and make the image edge smoother.
Shader setshader (shader) // sets the shadow. The shader class is a matrix object. If it is null, the shadow is cleared.
Void setstyle (paint. Style) // set the style, which is typically filled with fill or stroke.
Void settextsize (float textsize) // you can specify the font size.
Void settextalign (paint. Align align) // text align
Typeface settypeface (typeface) // you can set the font. You can use typeface to load the font inside Android. Generally, the font is for Chinese characters, and some rom can be added by yourself, such as .
Void setunderlinetext (Boolean underlinetext) // specifies whether to set the underline. The Void setflags (paint. underline_text_flag) method is required.
Iv. Android. Graphics. rect
Rect can be understood as a rectangular area. Similar to a point, the rect class not only indicates the location description of a rectangular area, but also prompts android123 to help us calculate whether a collision (including) between images) relationship, which is useful for Android game development. Its main member contains three overload 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)
5. Android. Graphics. Region
Region in the Android platform indicates that a region is different from a rect. It represents an irregular shape, which can be an ellipse, polygon, and so on. rect is just a rectangle. The Boolean contains (int x, int y) Member of the same region can determine whether a vertex is in the region.
6. Android. Graphics. typeface
The typeface class is used to help describe a font object. In textview, you can use the settypeface method to create a font of the output text. directly construct the typeface class and call the member create method to directly specify a font name and style, for example
Static typeface create (typeface family, int style)
Static typeface create (string familyname, int style)
The isbold and isitalic methods can be used to determine whether the fonts in bold or italic are included.
Final Boolean isbold ()
Final Boolean isitalic ()
This class can also be created from APK resources or from a specific file path. The specific method is
Static typeface createfromasset (assetmanager Mgr, string path)
Static typeface createfromfile (file path)
Static typeface createfromfile (string path)
We have sorted out the images and images of the Android platform in the previous two sections. Next time, we will first describe the ninepatch instance application.

This article is transferred fromWww.35java.com

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.