Android: no more than 1 nine patches at a time?

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

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <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 name of drawbales is "appwidget_bg.9.png". This stuff works great. But I would like to use different images for focused and pressed states.

So, I do it like this:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <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>

Problem: as soon as I add the extra drawable "appwidget_bg_pressed.9.png", I get the following error message:

... / res / drawable / widget_bg.xml: 21: ERROR error: resource not found that matches the specified name (in 'drawable' with the value '@ drawable / appwidget_bg').

.../AndroidManifest.xml: 6: ERROR: , ( "" "@drawable/icon" ).

, , drawables. ?

+3
2

, drawables? , . 9 . , appwidget_bg_pressed.9.png, appwidget_bg.9.png icon.png

+1

, , .

9-patch drawables; . , , , .

, .

0

Source: https://habr.com/ru/post/1764215/


All Articles