I would like to know why do we use nine-patch ? I know is to shrink or stretch images but if I want to resize an image can't we just do it on a dedicated image editor like gimp for example ?
What is 9-Patch?
9-Patch images are stretchable, repeatable images reduced to their smallest size; users draw a right and bottom, solid black 1 pixel border to tell the system how to place the content within the image.
The 9-Patch is a PNG image with an added extension to the file name (filename.9.png), which allows the Android system to determine how the image can be stretched and contorted to meet the specific layout constraints.
The Android operating system reads the borders of these images to understand how to properly stretch the image itself and the content within the image such as text and effects.
9-Patch Theory
9-Patch gets its name from the fact that the overlay created breaks the image up into nine defined regions. Each region has specific stretch properties:
Corner Regions (1, 3, 7, 9) These regions are fixed and nothing inside them will stretch.
Horizontal Sides (4, 6) The pixels in these region will stretch vertically when necessary.
Vertical Sides (2, 8) The pixels in these region will stretch horizontally when necessary.
Center (5) The pixels in this region will stretch in both horizontal and vertical directions equally.
here is Google docs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With