Smart phones often have the function of automatic horizontal screen, the same interface in the mobile phone (or tablet) in the direction of the sensor will change the direction of the display, after the interface changes direction, the interface graphics will be due to the length and width of the changes resulting in stretching, resulting in deformation of the graphics. For example, the following graphic is displayed normally on a vertical
A graphic that is distorted when it is displayed on a horizontal screen:
This is really too ugly.
To solve this problem, Android has a graph with the extension ". 9.png" that can solve this problem. Using the tool Sdk/tools/draw9patch.bat, you can start a graphical tool by clicking on the mouse. How to use
1. Use Draw9patch.bat to open the graphic you want to edit, depending on:
2. Next, using the left mouse button, in the upper left corner of the graph (left, top) respectively, draw a black line to indicate that you need to stretch the upper and left parts, note: These parts are often to stretch the background, horizontal lines and vertical line cross the area do not want to be deformed in the graph of the eagle.
3. Next, use the left mouse button, in the lower right corner of the graph (right and bottom) to draw a black line to indicate your left and below to stretch the site, the same reason.
4. If you want to modify a drawn line, hold down the SHIFT key, and then press the left mouse button.
5. After painting, File->save, the default will be saved as. 9.png, in this case the file name is eagle.9.png.
6. Specify this file name in your Android project, for example:
<?xml version= "1.0" encoding= "Utf-8"?>
<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
android:orientation= "Vertical"
Android:layout_width= "Fill_parent"
android:layout_height= "Fill_parent"
android:background= "@drawable/eagle"
>
<textview
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"
android:text= "@string/hello"
/>
</LinearLayout>
7. Copy the eagle.9.png to the following directory in the project:
8. Run the project with the following conditions:
1) Vertical screen:
2) Horizontal screen:
What do you say, no deformation? Oh.....
Of course, there are a lot of ways to make the graphics non-deformed, I just use it. 9.png.
Android in the. 9.png