Android development: Figure 9 Production instructions, android Development and Production

Source: Internet
Author: User

Android development: Figure 9 Production instructions, android Development and Production
Conclusion: the points on the left represent the vertical stretch area,
The above points represent the area of horizontal stretching.


Vertices on the right represent vertical cocoa display areas such as text,

The vertices below represent the horizontal display areas of text and so on.


The upper-left overlap area is the stretch area.

The area in the lower right is the display area.


Reprinted as follows:

Is a special image format in the application software development of the andriod platform. The file extension is .9.png.

The smart phone has the automatic horizontal screen function. The same interface will change the display direction with the parameter of the direction sensor in the mobile phone (or tablet). After the interface changes the direction, the image on the interface is stretched due to the variation of the length and width, resulting in distortion and deformation of the image.

We all know that the android platform has a variety of different resolutions. After the cut image files of many controls are enlarged and stretched, the corners are blurred and distorted.

OK. Using the PNG technology on the android platform, you can stretch the image horizontally and vertically at the same time to achieve a perfect Display Effect in multiple resolutions.

[Comparison of ordinary stretch and dot-nine stretch effects]

Obviously, after, the gradient texture of the image and the fineness of the rounded corner can still be preserved.

We can also understand why it is called "PNG png". In fact, it is equivalent to dividing a PNG image into nine parts (nine cells) with four corners and four sides, and in an intermediate area, the four corners are not raised, so they can still keep the rounded corners in a clear state, while the two sides are horizontally and vertically stretched, respectively, therefore, the side will not be grayed out, and only the area specified by the black line is stretched in the middle. The result is that the image is not displayed.

Ii. How to create "Point 9"

Method 1: Use the draw9patch tool to draw the image. The procedure is as follows:

1. install java on your computer in the default directory of the system. Without installing java can be searched in Baidu: jdk-6u20-windows-i586, installation package size 80 m around. Then, use the andriod Simulator-android-sdk-windows to open the "draw9patch. bat" file under the SDK/tools directory. The loading window is displayed:

2. Import and edit

Drag a png Image to this window.

For example, the editing page is automatically displayed. The figure shows the content and function comments of each region.

Preview the view on the right and find that the image edge is in normal stretch state.

Click the left button on the image edge to draw a black line, that is, the part of the image to be stretched. For example, four black lines are commented.

If you fail to draw multiple parts, you can press the shift key and click the left mouse button to erase them ).

As you can see, the three stretching results have been perfectly displayed, and we have achieved the desired stretching effect. Suppose this is a form with displayed text, then the text display area, the program will also control the corresponding range of the black line.

The following images, including non-regular images, can be scaled horizontally and vertically by clicking "9. PNG.

[Other draw9patch. bat functions]

② Show lock: display areas that cannot be painted

② Show patches: preview the extended cells in this drawing area (pink represents an extended area)

③ Show patches: highlighted area (purple area) in the preview View)

④ Show bad patches: adds a red border around the gongge area, which may produce manual traces when the image is extended. If you eliminate all bad cells, the visual consistency of the extended view will be maintained.

3. Save and Output

Click file-save on the top left to save the file. An image with the suffix "* .9.png" is automatically generated. A black line of 1px is added to the upper and lower sides of the image.

Method 2: Use a flat tool such as PS to plot the image. The flowchart is as follows:

As shown in the flow chart, only two steps are required to get the .9.png image. The specific steps are as follows:

1. determine the size of the image canvas after cropping,

2. manually add 1px to the upper, lower, and left sides

3. Use a Pencil tool to manually draw the stretch area. The color value must be black (#000000 ).

4. Use the webformat for storage. Select png-24and manually change the suffix to .9.png.

However, the disadvantage of this method is that it cannot be previewed in real time to determine and test the accuracy of the stretch area.

Note the following two points when using this method:

1. The stretched area of the hand-drawn black line must be #000000, with a transparency of 100%, and no translucent pixels can appear on the four sides of the image;

2. Your .9.png must have a black line in the stretch area;

Otherwise, the image will not be compiled by the android system, causing an error in the program. Still, why is the black line in the .9.png image missing after the compressed APK file?

This is because when the andriod program packs the file into an apk, the program will automatically remove the black lines at the edge of the * .9.png image, so as to uncompress The. 9.png file after the apkfile, there will be no black lines.

Iii. Significance of using "Point 9"

After testing, it is found that the display effect of normal png is obviously discolored. And .9.png Image Display Effect is obviously better than normal png.

After the format of .9.png is used, the problem of horizontal stripes is basically solved. For .9.png images, the android system program has an optimized algorithm.

The material quality of the android mobile phone screen varies greatly. Many screens do not support color display with more than 16 digits.

Therefore, after rendering, the color is lost, resulting in a horizontal display.

After comparison with a variety of android phones, it is found that the more obvious the screen is, the more obvious the screen is.

After * .9.png image technology is used, you only need to use a set of interface slashes to adapt to different resolutions, and greatly reduce the size of the installation package. In addition, the program can be stretched without special processing, which reduces the amount of code and Development workload.


How to Use psto create images

1. Use Photoshop to draw point 9.

Determine the size of the canvas after the image is cut,
Manually add 1px to the upper, lower, and left sides
Use the Pencil tool to manually draw the stretch area. The color value must be black (#000000 ).
Use the webformat for storage. Select png-24. manually change the suffix to .9.png.
However, the disadvantage of this method is that it cannot be previewed in real time to determine and test the accuracy of the stretch area.

Note the following two points when using this method:
1. The stretched area of the hand-drawn black line must be #000000, with a transparency of 100%, and no translucent pixels can appear on the four sides of the image;
2. Your .9.png must be painted with a black line in the stretch area.

2. What is it.
1. "Point 9" is a special image format in the application software development of the andriod platform. The file extension is .9.png.
In fact, it is equivalent to dividing a png image into nine parts (nine cells) with four corners, four sides, and an intermediate area.

2. Example
In this figure, only the area specified by the black line is stretched.

The area where the black strip position falls indicates that when the image is horizontally stretched, only the area where the black strip position of the Area 2 is to the right indicates that the image is vertically stretched, only the black bar 3 in this area is stretched to the left-covered area, indicating the area where the image is displayed vertically. the area where the black bar 4 is located is covered up, indicating that there are no black bars in the area where the image is displayed horizontally. the area covered by the position is unchanged when the image is stretched (for example, if the four corners of the image are curved, the arc shapes of the four corners will not change when the image is stretched)

Reference website: mux.baidu.com /? P = 1506
Bbs.51cto.com/thread-954672-1.html



What do you need to learn about underlying Android driver development? For details,

Android is a mobile platform that runs java programs based on linux kenerl. For underlying development, you need to understand the c/c ++ language, be familiar with linux kenerl, and understand UNIX technical specifications.

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.