Android Studio,9 Patch 和 "Show Bad Patches" 按钮。它怎么知道?

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

我正在尝试清理一个包含大量九个补丁图像(50 个左右)的大型项目。我发现的一件事是,当 android 项目从 Eclipse 迁移到 Android Studio 时,系统会查看 9 个补丁映像以确保它们符合标准。我收到很多 gradle 错误。

我见过的对 9 补丁的最好描述是 simple guide to nine patch.

Android Studio 包含一个 9 补丁编辑器工具。正是使用该工具将我带到了这里。该工具有一个切换 "Show Bad Patches / Hide Bad Patches" 的按钮。我正在努力理解 "Bad Patches."

的概念

参考: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.

参考:Android Developer guide on 2d graphics. 该指南说 'Show Bad Patches' 按钮 ...

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.

这是我正在查看的文件的屏幕截图:

所以这是交易。无论我做什么,我的图形上总是会出现一些坏补丁。您如何 'clean' 上传图像以避免出现错误补丁?

为什么我的屏幕上会显示那些红框?我一直在玩图像和 1 像素边框,但不确定从这里去哪里。有人知道这里发生了什么吗? Nirvana.9.png是什么样子的?

我刚刚发布了一篇关于 Bad Patches 的 Medium post - 请随时查看:

9-patch: bad patches everywhere…