Eclipse bug with nine patch files?
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 开发者_StackOverflowtry 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:
And here is a screenshot:
Is there a problem in my .9.png or is it a problem with eclipse?
Thanks
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.
- Let assume your image name is image.9.png
- Use the refactor to rename the file: image9.png (I remove the dot in from of the 9)
- 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.
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.
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.
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.
精彩评论