Android .9.png image creation

Source: Internet
Author: User

Android .9.png image creation

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]

Signature + signature + xVBOR6Gxo6zG5Mq1z + signature/Signature/R + TwvcD4KPHA + CiA8L3A + signature/Signature + 37vm1sajrMH3s8zI58/Signature "68" src = "http://www.bkjia.com/uploads/allimg/150214/0411462337-1.jpg "alt =" \ "width =" 540 ">

1. Install the tool

First, you need to 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. Something

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. Something about the internet

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

[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: The 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 the Internet

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: yixieshi

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 ). Something

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 be painted with black lines in the stretched 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? Something

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.

3. Something about the Internet with the meaning ""

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.

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.