android - 图形布局不会显示我的按钮背景

标签 android eclipse

我在 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 并切换到“图形布局” View ,我看不到背景图像完全没有,在我看到的图形 View 下面

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

couldn't resolve resource @drawable/but_easy_p

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

最佳答案

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

关于android - 图形布局不会显示我的按钮背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15026019/

相关文章:

java - 当ListView的Item被选中时如何关闭抽屉导航?

android - 如何使用 GitHub 上的 OpenStreetMap 库

android - 如何更改选项菜单点的颜色?

安卓账户管理器

eclipse - 编写 Eclipse 插件时,检查 IEditorPart 是否是 Java 编辑器的正确方法是什么?

c++ - VALGRIND:大小为 8 的无效读取

android - <uses-sdk> 标 checkout 现在 <application> 标签之后

java - 如何在 Eclipse IDE 中的 Apache Tomcat 服务器中部署创建的 .jar 文件?

java - 带有 64 位 JVM 的 32 位库

android - 使用 Android 模拟器的 Eclipse 中出现错误 "AdbCommandRejectedException: device not found"