Ninepatch can process. png images, generate a. 9.png format picture, image stretching operation, the picture will be distorted, and. 9.png is a special image format supported by Android, which allows partial stretching.
How to make a picture:
1. Prepare a original picture
2. Open: Sdk/tools/draw9patch.bat
3. Menu File->open. Open picture
4, the left is the editing area, the right picture is a preview, in the area outside the picture, click to draw the black line, press shift+ Click to erase the black line, the length of the black line determines the stretch of the area.
5. Save. 9 Chart, Menu: File->save ... Enter the name to automatically export the. 9.png format picture (Eclipse will be an error if you don't have a black line in 9.png)
Use:
android:background= "@drawable/box"
Instance:
<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical" > <ImageViewAndroid:layout_width= "100DP"Android:layout_height= "100DP"Android:background= "@drawable/box" /> <ImageViewAndroid:layout_width= "200DP"Android:layout_height= "100DP"Android:background= "@drawable/box" /><ImageViewAndroid:layout_width= "300DP"Android:layout_height= "200DP"Android:background= "@drawable/box" /></LinearLayout>
Effect: