Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When should I use 9 patch image in android

Please help me to understand on when i have to make decision to define 9 patch image. what i have understood is, 9-patch image is require only when i have defined my layout width and height with definite size but actually i don't have image of that size. let's say, i have set background size as 300*100 in my layout definition. but image i have 200*100, which is lesser size then what i need. in this case if i do define 9 patch image, will help to fit properly without compressing quality in all devices.

This where i used to 9 patch.

Now, what i want to understand is, does 9 patch image will scales on different screen resolution even if i have defined our layout definition as wrap content, match parent with no explicit value on width and height. does 9-patch will scale based on screen resolution?

like image 315
chethan Avatar asked Aug 17 '16 07:08

chethan


1 Answers

What are exactly nine patch -
The 9-Patch is a modified PNG image that allows Android to determine how the image can be stretched to meet the specific layout during runtime(like fill_parent and wrap_content).

Common Usege -
1. Button backgrounds. (Default Android gray Button is a Nine-Patch)
2. Page backgrounds.
3. Splash screens.

Step-by-Step guides-
1. Edit NinePatch in Android Studio.
2. Best practice design usage here.

like image 120
Nir Duan Avatar answered Sep 24 '22 12:09

Nir Duan