How can I develop a 9-patch image?
Is there any tool? Can I create it from AndroidSDK or code?
Main Advantages of 9-patch over routine png?
( is it elastic dynamically/ instantly inning accordance with evaluate?).
Today I found 9 spot images. The official documents (connected to in the other answers) is okay I suppose, but it actually does not have in examples.
This little tutorial has some great examples at the end that answer the 2nd part of your question, discussing how the scaling works – not just for buttons – however also frames, and it has a total example project that you can download and play with. The most important advantage over PNG is that 9 spot images can specify non-contiguous locations to scale.
To answer the very first part of your concern, the SDK (and now Android Studio) ships with “Draw 9-patch” (” draw9patch” in the SDK tools folder) which is a simple editor. Here is a better one which is also open source. It has a creative but basic default image.
The majority of the examples speak about developing a 9-patch image, however implementation details are typically left at a high level.
Recommendation the drawable with the name however do not include.9.png (auto-complete in eclipse will look after this).
Make certain you just have 1 image under the main/ drawable folder (not a variation for each dpi folder).
The image must be specified utilizing: background, not: src (this got me stuck for a while).
android: background=” @drawable/ splash_logo”
Make certain the image and design which contains it are utilizing:.
android: layout_width=” fill_parent”
When you browse a major search engine for android 9-patch tool, the first hit is for the Android designer documentation page on the draw9patch tool.
The Android developer documents contains other pages that explain nine-patch PNG files. This documentation consists of passages like:.
A NinePatchDrawable graphic is a stretchable bitmap image, which Android will automatically resize to accommodate the contents of the View in which you have actually placed it as the background. An example use of a NinePatch is the backgrounds used by basic Android buttons– buttons should stretch to accommodate strings of different lengths.
With 9-patch image you can choose which part of your image might be extended. It must be png image and name should end with.9.png (something.9. png).
NinePatch images are PNG images that mark the parts of an image that can be extended. They have an extension like image_name.9. png.
Actually 9 Patch images are stretchable, repeatable images minimized to their smallest size.the image will not stretch and loose percentages in different screen sizes. One more and greatest benefit is memory.
Exact same little size memory can be recycled for various screen size gadgets. Properly designed 9-patch images are less error-prone and have high re-usability.
9 Spot images are stretchable, repeatable images minimized to their smallest size. If you were to take a rounded div and slice it up into 9 squares like you would a tic-tac-toe board, the most basic example would be. The 4 corners would not change sizes at all but would be static while the other 5 pieces would be extended or repeated to allow the entire image to scale properly.
With that explanation and the introduction of CSS3 you might think that there is no factor to utilize 9 patch images however the name ‘9 spot’ is a misnomer. The images can be sliced into even smaller sized pieces.
9 Patch images include an index which piece is exactly what by including a 1px border to the image. The colors in the border identify if a piece is fixed (doesn’t scale), it extends, or it repeats.