Android Custom View Learning Note 03

Source: Internet
Author: User

Android Custom View Learning Note 03 Pre-knowledgeBitMapClass

BitMapThe bitmap class, which has a nested class called Bitmap.Config , has four enumerated values inside. The purpose of this class is to define the quality of bitmap storage, that is, the number of bits stored in a pixel, and whether transparent, translucent colors (Possible bitmap configurations) can be displayed. A bitmap configuration Describes how pixels is stored. This affects the quality (color depth) as well as the ability to display transparent/translucent colors).

A Transparency R Red G Green B Blue
Bitmap.config Alpha_8 Only stores transparency, other colors are not stored
Bitmap.config argb_4444 16 per pixel four bits
Bitmap.config argb_8888 32 per pixel eight bits
Bitmap.config rgb_565 5-bit G accounted for 6 bits B accounted for 5 bits no Transparency (A)
Reference Blog

Rectangle class
    1. RectClass, a rectangle is formed by defining four (left, top, right, and bottom) edges. What is awkward is that the parameter represents the distance from the x-axis or the y-axis of each edge.
    2. RectFClass, ditto, different Rect parameter types are shaped, with F is a single-precision floating-point number. In addition, Rect objects can be constructed as arguments RectF .
A very important class.BitmapShaderBitmap renderer

BitmapShaderThe bitmap renderer, which uses bitmaps as textures to paint, sets a pattern to set different rendering effects (Shader used to draw a bitmap as a texture. The bitmap can repeated or mirrored by setting the tiling mode).

    • Construction method BitmapShader(Bitmap bitmap, Shader.TileMode tileX, Shader.TileMode tileY) , the parameters are, as the texture of the bitmap, the horizontal direction of the rendering method, the vertical direction of rendering.
    • There is a nested class Shader.TileMode tile pattern, which defines three enumerated types of variables.

CLAMPIf the renderer is outside the original boundary range, the color of the original boundary is copied out of the range.
REPEATIf the display range is larger than the size of the picture, the picture is repeatedly rendered horizontally and vertically, tiled.
MIRRORlike the previous one, it's just a mirror tile.
The first parameter is used for general use.

    • The method for setting the warp matrix public void setLocalMatrix(Matrix localM) .
    • Reference Blog Android Learning notes advanced 16 Bitmapshader
PaintClass

There is a method in the class that sets Shader the Renderer object public Shader setShader(Shader shader) to set the renderer.

MatrixMatrix class

MatrixThere is a 3*3 matrix inside, there are deformation information, there is no constructor function. Only specific methods can be used to set the relevant parameters. This matrix is divided into four parts, namely proportional rotation, translation, proportional transformation, perspective transformation. Operation principle is the transformation of the Matrix, refer to the Android matrix theory and application of the detailed
-Set the method for scaling, with the public void setScale(float sx,float sy) parameters being horizontal and vertical scaling.

Not finished

Android Custom View Learning Note 03

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.