android nine-patch image

访问量: 993


refer to:


To create a nine-patch image, you can either use the Android SDK draw9patch tool or a graphics editor. If you are using a graphics editor, create a one-pixel transparent or white border around your PNG image, then change the top and left border to black pixels where you want the image to stretch. Mark the entire right and bottom borders with black pixels to indicate the drawable areas when the image is scaled. If you do not specify the whole image as drawable, the image may not scale properly, causing it to be squished in part of the screen. For more information, refer to the Android Draw 9-Patch help tutorial for directions on using the draw9patch tool or refer to the Android nine-patch image specification for information on creating a nine-patch image in a graphics editor.

Name the file default.9.png, place it in the Resources/android folder and remove the default.png image. If both of these files exist, the build will fail with an error.

To use multiple density-specific splash screen images, copy your nine-patch image(s) to ./platform/android/res/drawable[-xdpi]/ in your project root directory (not the Resources folder), where xdpi can be a density group to specify more than one image for different screen densities or use the -nodpi suffix to have it support all resolutions. Rename the file(s) to background.9.png. For example, the following project specifies splash images for multiple densities:

├── app
├── platform
│ └── android
│ └── res
│ ├── drawable-ldpi
│ │ └─── background.9.png
│ ├── drawable-mdpi
│ │ └─── background.9.png
│ ├── drawable-hdpi
│ │ └─── background.9.png
│ └── drawable-xhdpi
│ └─── background.9.png
├── Resources
└── tiapp.xml

订阅/RSS Feed