9 つのパッチ イメージ ( **.9.png ) に問題があります。ウィジェットのレイアウトがあり、ウィジェットの背景に 9 つのパッチ イメージを使用したいと考えています。ここに私の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>
ドローベールの名前は「appwidget_bg.9.png」です。このようなものはうまくいきます。しかし、フォーカス状態とプレス状態に別の画像を使用したいと思います。
だから私はそれを次のようにします:
<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>
問題: ドローアブル「appwidget_bg_pressed.9.png」を追加するとすぐに、次のエラー メッセージが表示されます。
.../res/drawable/widget_bg.xml:21: エラー エラー: 指定された名前に一致するリソースが見つかりません (「drawable」で値「@drawable/appwidget_bg」)。
.../AndroidManifest.xml:6: エラー エラー: 指定された名前に一致するリソースが見つかりません ('icon' で値 '@drawable/icon')。
drawables フォルダーに追加できるのは 9 パッチのドローアブル 1 つだけのようです。何故ですか?