views:

193

answers:

2

Hi,

I am having problems with nine patch images ( **.9.png ). I have a widget layout and would like to use nine patch images for the widget's backgroud. Here is my background.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/appwidget_bg" />
    <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/appwidget_bg" />
    <item android:state_focused="true" android:drawable="@drawable/appwidget_bg" />
    <item android:state_focused="false" android:drawable="@drawable/appwidget_bg" />
</selector>

The drawbales name is "appwidget_bg.9.png". This stuff works fine. But I would like to use different images for the focused and pressed states.

So I make it look like this:

<selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/appwidget_bg_pressed" />
    <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/appwidget_bg_pressed" />
    <item android:state_focused="true" android:drawable="@drawable/appwidget_bg_pressed" />
    <item android:state_focused="false" android:drawable="@drawable/appwidget_bg" />
</selector>

The problem: As soon as I add the additional drawable "appwidget_bg_pressed.9.png" I get the following error message:

.../res/drawable/widget_bg.xml:21: ERROR Error: No resource found that matches the given name (at 'drawable' with value '@drawable/appwidget_bg').

.../AndroidManifest.xml:6: ERROR Error: No resource found that matches the given name (at 'icon' with value '@drawable/icon').

It seems like I can only add one nine patch drawable to the drawables folder. Why is that?

+1  A: 

Are you certain they've been imported into your drawables folder? That error is saying it's not found the files. You can certainly have multiple 9-patch images. Seems like it's found appwidget_bg_pressed.9.png, but isn't seeing just appwidget_bg.9.png or icon.png

kcoppock
yeah, that's what it looks like. somehow like the new one "appwidget_bg_pressed.9.png" is blocking something... i can not figure what's wrong with it.
Johe Green