9补丁图像错误

时间:2016-04-06 16:52:16

标签: android android-studio png nine-patch aapt

我有一个可以构建和工作的项目,但我的图像(png)并不适应手机。

实际上,我有10张图片,我将它们放在所有可绘制的文件夹中: -drawable-hdpi有10张图片 -drawable-mdpi有10个SAMES图像(同名,相同大小,相同分辨率) - ... xhdpi,xxhdpi,xxxhdpi

相同

1)我尝试使用SimpleAs-patch Generator,从AndroidAssetStudio这样:http://romannurik.github.io/AndroidAssetStudio/nine-patches.html

  • 我拍摄了第一张图片,将其上传到生成器,下载了zip文件,并将每个文件解压缩到正确的文件夹中。
  • 然后我运行我的应用程序,我收到了这个错误:

    错误:9-patch image ../../IMAGE_1.png格式错误。帧像素必须是 固体或透明(非中间alphas)

2)然后我尝试回到原来的.png,并使用/ Android / Sdktools / draw9patch,并将.9.png生成在右侧文件夹中。

我收到了这个错误:

ERROR: 9-patch image ../../IMAGE_1.9.png malformed.
AAPT:        No marked region found along edge.
AAPT:        Found along top edge.

这是我的原始图片之一:

p11_titre.png

以及生成的版本:

enter image description here

1 个答案:

答案 0 :(得分:2)

OK, this is your 9 patch.
There's a bad pixel on the bottom marker.

enter image description here

And this is how it will stretch, due to the markers you set.

enter image description here


This is my fixed version (note the top markers: 2 single pixels)

enter image description here

And this is how it nicely stretches (width only, because of the curved edges - You can add a transparent line on top and bottom to make it leave some "space", the left side markers would then have to be made 2 single pixels, one per each transparent line).

enter image description here