用于阴影的标准 9 补丁生成器生成 9 个无法编译的补丁

Standard 9 patch generator for shadows produces 9 patches which won't compile

我一直在尝试使用这个 http://inloop.github.io/shadow4android/,但是它绘制的所有 9 个补丁都无法用 Android studio 编译。有人有修复或替代方案吗?我正在尝试绘制阴影。

AAPT: error: file failed to compile.

当我在 Android Studio 中查看 9 补丁编辑器时,它没有显示任何错误补丁。

我需要控制阴影的颜色,我正在使用 Cardview。

我在你提到的网站上生成了一个 9 补丁。在 Android Studio 中我看到这个错误:

AAPT: error: found an invalid color.
...path to directory...
shadow_95536.9.png: error: file failed to compile.

直接运行aapt出现如下错误:

aapt c -S . -C .\tmp
Crunching PNG Files in source dir: .
To destination dir: .\tmp
ERROR: 9-patch image shadow_95536.9.png malformed.
Frame pixels must be either solid or transparent (not intermediate alphas).
Found at pixel #26 along bottom edge.

在图像编辑器中检查后,很明显图像底部有一个像素具有 alpha,而不是 aapt 错误消息中所述的完全不透明或透明。通过使它 100% 透明来删除有问题的像素解决了编译问题。

如果这是您遇到的问题,请在您选择的图像编辑器(我使用 GIMP)中检查 9 色块的边界并更正有问题的像素。