When should I use 9 patch image in android
Asked Answered
U

1

8

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?

Ubangishari answered 17/8, 2016 at 7:47 Comment(2)
developer.android.com/reference/android/graphics/NinePatch.html , its just act as normal image where based on parents request it will be in same or expanded size.Fondness
developer.android.com/guide/topics/graphics/…Mvd
I
7

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.

Idaliaidalina answered 17/8, 2016 at 8:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.