1

我在 res/drawable 目录中自己的“custom_easy_but.xml”中有一个按钮背景,如下所述:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
        <item android:drawable="@drawable/but_easy_p"
    android:state_pressed="true"/>

    <item android:drawable="@drawable/but_easy" />

</selector>

然后我有一个名为 modeselect.xml 的布局,其中包含以下代码:

<Button
    android:id="@+id/easy"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginRight="10dp"
    android:background="@drawable/custom_easy_but"
    android:text="@string/Easy" />

然后我在名为 but_easy.png 和 but_easy_p.png 的文件中有一组不同大小的图像,分别位于 res/drawable-large 和 res/drawable-normal 目录中。该代码在各种手机上编译、运行和显示正确的按钮背景图像......但如果我使用 eclipse 查看文件 modeselect.xml 并切换到“图形布局”视图,我看不到背景图像根本没有,在我看到的图形视图下面

failed to parse file c:\blah\blah\res\drawable\custom_easy_but.xml

couldn't resolve resource @drawable/but_easy_p

真手机怎么能把所有的xml都整理出来,而eclipse却不能呢?

4

1 回答 1

1

确保您在图形编辑器中设置了正确的屏幕尺寸。如果您选择了没有资源的屏幕尺寸,则不会显示您的布局。

于 2013-02-22T14:20:53.813 回答