When should I use 9 patch images in android

Please help me understand when I should decide to identify 9 patch images. what I understood, a 9-patch image is only required when I determined the width and height of a layout with a specific size, but in fact I don't have an image of that size. let's say I set the background size to 300 * 100 in my layout definition. but I have 200 * 100, which is less than what I need. in this case, if I define 9 patch images, this will help to properly adjust without compression quality on all devices.

This is when I used 9 patches.

Now I want to understand that 9 patch images will scale at different screen resolutions, even if I defined our layout definition as wrapper content, map the parent element without an explicit value in width and height. Will the 9 patch be scaled based on screen resolution?

+7
android android-layout nine-patch
source share
1 answer

What are nine patches -
9-Patch is a modified PNG image that allows Android to determine how the image can be stretched to fit a specific layout at runtime (e.g. fill_parent and wrap_content).

Normal use -
1. Buttons. (By default, the Android Gray button is a nine-patch)
2. Backgrounds of the page.
3. Screen savers.

Walkthroughs -
1. Edit NinePatch in Android Studio .
2. Use best practice design here .

+6
source share

All Articles