Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nine-patch versus Vector graphics

I am learning about Android UI and am unclear why people use nine-patch, when you could use vector graphics, because those are scalable without any pixel degradation. I am a beginner in Android, so I hope I am not missing anything here, but it seems like it would be easier to build vector graphics and use those. You would not need the special editor to build them.

Can anyone explain the advantages to using nine-patch over vector? (Don't just explain advantages of nine-patch, as that is already done on StackO., but rather the advantages that vector does not have). Because it seems like Android recommends nine-patch. Thanks.

like image 757
Azurespot Avatar asked May 15 '14 06:05

Azurespot


People also ask

What is a nine patch image?

The Draw 9-patch tool is a WYSIWYG editor included in Android Studio that allows you to create bitmap images that automatically resize to accommodate the contents of the view and the size of the screen. Selected parts of the image are scaled horizontally or vertically based on indicators drawn within the image.


1 Answers

i hate 9patches. i am quite attentive when doing my artwork. i don't even use photoshop. i go with illustrator. i do everything right when exporting my artwork, i used to do my 9 patches with insane zoom on, maybe check afther that in photoshop for misplaced pixels... ** sad trumpet ** when put on a view, if i used some subtle round corners like 6px or 10px and a stroke everything looks awful at mdpi.

So I solved my problems by marrying the two. I wrote my own 9patch which uses vectors. :)

Everything looks like it's been touched by baby Jesus. Perfect corners, strokes and, best of all, you can use one asset for all the screen sizes, densities while, of course, no more transparent borders, wicked errors because 9patch won't stretch inward, so on and so forth.

I use vectors for icons too. While there sometimes are issues with various effects, these are minimal and easily avoided if you do some reading on how to avoid them.

Best of luck to all you guys!

The same image, 9patched, kind of "offsets" the black outline of the buttons. so the strokes get misaligned.

This is a very basic example.

You can do whatever strikes your fancy. Because of the performance impact of svg's on an app, when first run [or when the user changes appearance options, i like to save the newly generated bitmaps as pngs, if possible.

You don't get any more "best of both worlds" than this.

like image 112
PauLEffect Avatar answered Oct 05 '22 01:10

PauLEffect