1

TheBackground.png という背景画像を持つ Eclipse Kepler の Android アプリがあります。

TheBackground.png を res/drawable-mdpi に追加し、activity_main.xml は次で始まります。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:background="@drawable/TheBackground.png"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

しかし、Eclipse は android:background 行でこのエラーをスローします。

指定された名前に一致するリソースが見つかりませんでした (値が「@drawable/TheBackground.png」の「background」)

すべての res/drawable-*dpi フォルダーに TheBackground.png を追加し、res/drawable フォルダーを作成してそこに追加しようとしましたが、同じエラーが返されます。

ファイル名は有効な PNG 画像を指していることに注意してください。

何か不足していますか?

4

5 に答える 5

2

描画可能に設定する場合、「.png」は必要ありません。そして小文字を使います。

android:background="@drawable/the_background"
于 2013-07-27T20:19:13.307 に答える
1

pngファイルの名前を小文字に変更

于 2013-07-27T19:55:10.860 に答える