Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:\...\res\drawable\appwidget.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:\...\res\drawable\appwidget.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?

like image 556
Heber Avatar asked Nov 25 '10 19:11

Heber


People also ask

What is 9 patch image when to use it in Android?

The Draw 9-patch tool is a WYSIWYG editor included in Android Studio that allows you to create bitmap images that automatically resize to accommodate the contents of the view and the size of the screen. Selected parts of the image are scaled horizontally or vertically based on indicators drawn within the image.

How do I create a 9 patch image in Photoshop?

Creating 9 patch background image using Photoshop:Draw the images in a regular way as you use to do in Photoshop. Make the 1px spacing around the image from all sides. And also make sure that the image doesn't have anything in this 1px area & has 100% transparency. Otherwise 9patch image will not work.


1 Answers

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.

like image 73
Jiawei Dai Avatar answered Sep 30 '22 18:09

Jiawei Dai