9 Patch images are repeatable and stretchable images which are reduced to their smallest size. The easiest case is taking a rounded div and cut it it up straight into 9 squares. Its 4 corners would not change sizes at everything except would be fixed while the other five pieces would be repeated or stretchedto enable the entire picture to scale appropriately.
You may believe that there is no reason to utilize 9 patch images however the name ‘9 patch’ is just a misnomer to help you understand. The images may be sliced up into considerably smaller pieces.
How different with normal png files?
9 Patch images are different from normal png files as they contain an index of which piece is the adding a 1px border to the picture. The colors in the outskirt determine if a piece is static, it repeats or stretches.
Here’s a quick guide to creating 9 Patch graphic utilizing the Draw 9-patch app in Android Studio. You’ll require the PNG picture with which you’d get a kick out of the chance to make a 9 Patch image.
In Android Studio, right-click the PNG picture you’d jump at the chance to make a 9 Patch image from, then click Create 9-patch document.
Sort a document name for your 9 Patch picture, and click OK. Your picture will be made with the .9.png document augmentation.
Double tap your new 9 Patch document to open it in Android Studio. Your workspace will now open.
The left pane is your drawing zone, in which you can alter the lines for the stretchable patches and content region. The right pane is the review range, where you can see your graphic when stretched.
Click inside the 1-pixel perimeter to draw the lines that define the stretchable patches and (discretionary) content range. Right-click (or hold Shift and clicK on a PC) to delete previously drawn lines.
Whenever done, click File > Save to spare your changes.
You can open an existing 9 Patch image in Android Studio by double tapping the document.
To make sure that your 9 Patch graphics scale down legitimately, verify that any stretchable regions are no less than 2×2 pixels in size. Else, they may disappear when scaled down. Additionally, give one pixel of additional safe space in the graphics previously, then after the stretchable regions to maintain a strategic distance from interpolation amid scaling that may cause the color at the boundaries to change.