Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
169 views
in Technique[技术] by (71.8m points)

9-patch image error in Android

Whenever I try to add a 9-patch image to the drawable folder in my project, I get the same error:

ERROR: 9-patch image C:...
esdrawableappwidget.9.png malformed.
Frame pixels must be either solid or transparent (not intermediate alphas).
Found at pixel #3 along top edge. Failure processing PNG image
C:...
esdrawableappwidget.9.png

The weird thing in this example is that I've got this image from the "android-g1-icon" images found in the SDK resources, so it is supposed to be OK. The same happened with any 9-patch image I've tried so far. What could be wrong?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I have encountered with same problem on Android Studio:

AAPT out(943142208) : No Delegate set : lost message:Done
AAPT err(943142208): ERROR: 9-patch image /Users/cartman/Github/UteacherAndroid/RefactorDemo/app/src/main/res/drawable-xxhdpi/nav_shabow.9.png malformed.
AAPT err(943142208):        Frame pixels must be either solid or transparent (not intermediate alphas).
AAPT err(943142208):        Found at pixel #1 along left edge.

This is how I resolved it: Open draw9patch tool under your Android Sdk directory

cd /Android/sdk/tools
./draw9patch

Open .9 png and save it again. Hope it helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...