Eclipse bug with nine patch files?
Asked Answered
S

5

9

I tried to convert all my buttons background to .9.png, but I have a problem with Eclipse.

I created my nine patch .png with the tool, but since I put it in my /res/drawable folder, I have the following errors in all my .xml files when I try to access any resource starting with @drawable:

Error: No resource found that matches the given name (at 'drawable' with value '@drawable/my_resource').

Here is my .9.png: nine patch

And here is a screenshot: screenshot

Is there a problem in my .9.png or is it a problem with eclipse?

Thanks

Saipan answered 3/12, 2010 at 16:14 Comment(2)
btw: reg. "I put it in my /res/drawable folder..." - you don't have a drawable folder (referring to your screenshot), only drawable-hdpi, etc. That's on purpose, right?Transvestite
Yes it is. The @drawable resolves correctly. It's just weird, because if I just remove the .9.png, everything works fine, but if I add it back, Eclipse won't be able to resolve any drawable resource...Saipan
M
8

I don't know for sure that it's what's causing the problem, but in your NinePatch, you need to make the right and bottom part of the frame into solid lines. The right and bottom define your content area (i.e. where Android will place content within the NinePatch. It can't be a discontiguous area.) The top and left define your stretch points. Since it's a gradient, I would go ahead and just connect the dots on all sides except the top. The top, you can just use a single black pixel to achieve the same result.

Misuse answered 3/12, 2010 at 16:18 Comment(2)
Basically, you can have multiple stretchable areas (top/left dots), but only one content area (bottom/right dots, or the entire area if you leave the bottom/right blank). You need to have one continuous line or no line on the right and bottom for a ninepatch to be legal.Group
Thanks to both of you, that was exactly the problem. I was just not using the draw 9patch tool right!Saipan
I
1
  1. Let assume your image name is image.9.png
  2. Use the refactor to rename the file: image9.png (I remove the dot in from of the 9)
  3. Then use the refactor again to rename it back to the original name: image.9.png

I am assuming that the configuration file is not being updated correctly so the use of refactor force the updating of whatever file is being use for configuration.

Imogene answered 27/6, 2011 at 13:12 Comment(0)
T
0

Are you referencing to "my_resource" (.9.png) anywhere in the code? Cause your button is named "button_blue", but the image in the error log is "my_resource". Search the project for any class or xml containing 'my_resource'. If there's none, try to clean the project in Eclipse (Menu / Project / Clean...) and/or restart Eclipse.

Transvestite answered 3/12, 2010 at 16:18 Comment(1)
Yes, The call to the nine patch resource is actually in the screen shot, I just changed the error message to a more generic one as it displays an error when I try to access ANY @drawable resource, and not only the nine-patchSaipan
K
0

I had the same problems. The same errors. For all drawables including ninepatch.

The instruction in http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch says that I have to put files in drawable, not drawable-hdpi. Or mdpi as I had it. So, I created simply "drawable" folder. And moved everything there. It wont work, either. BUT when thereafter I moved all back, it worked OK. It is all magic, I am afraid. Cleaning and building are not the reason - I made them after every change.

Kenlay answered 20/5, 2011 at 8:2 Comment(0)
M
0

For working perfect try to close and open 9patch after modification.

it preferebly to close 9patch for each modifcation image, and re open 9patch for the new image that you want streatch with 9patch.

Malines answered 19/2, 2013 at 18:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.