Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio, 9 Patch and the "Show Bad Patches" Button. How do it know?

I'm trying to clean up a large project which has a lot of nine patch images (50 or so). One thing I'm finding out is when an android project migrates from Eclipse over to Android Studio, the system looks at the 9 patch images to ensure they comply to a standard. And I'm getting lots of gradle errors.

The best description I've seen for a 9 patch is simple guide to nine patch.

Android Studio includes a 9 patch editor tool. It's the use of that tool that brought me here. The tool has a button that toggles "Show Bad Patches / Hide Bad Patches". I'm struggling trying to understand the concept of "Bad Patches."

Reference: Android document, describing the use of that button.

Show bad patches: Adds a red border around patch areas that may produce artifacts in the graphic when stretched. Visual coherence of your stretched image will be maintained if you eliminate all bad patches.

Reference: Android Developer guide on 2d graphics. That guide says the 'Show Bad Patches' button ...

raises warnings if the region you've defined for the stretchable area is at risk of producing drawing artifacts as a result of the pixel replication.

Here is a screen shot of the file I'm looking at:

Screen shot from my laptop Ubuntu 14.04 with Android Studio 1.0.2

So here's the deal. No matter what I do, I always have some bad patches visible on my graphics. How do you 'clean' up an image to avoid bad patches?

Why are those red boxes displayed on my screen? I've been playing with the image and the 1 pixel borders, but not sure where to go from here. Anybody understand what is happening here? What does Nirvana.9.png look like?

like image 601
zipzit Avatar asked Feb 04 '15 00:02

zipzit


1 Answers

I have just published a Medium post about Bad Patches - feel free to check it out:

9-patch: bad patches everywhere…

bad patches

like image 89
Bartek Lipinski Avatar answered Sep 30 '22 04:09

Bartek Lipinski