Android XML 查看器失败

发布于 2024-11-27 22:30:50 字数 1117 浏览 0 评论 0原文

我遇到这个问题已经有一段时间了:

这是我的 header.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical">


<ImageView android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:src="@drawable/logo_text"/>

</LinearLayout>

这是 Eclipse/Android XML 查看器给我的:

Unable to resolve drawable "C:\Users\Me\MyApp\res\drawable-hdpi\logo_text.png" in attribute "src"

这种情况也发生在其他项目中以及看似随机的图像中。项目->清理也没有帮助。我知道这一定是我的机器或 eclipse 安装的问题,因为它不会发生在我的工作机器上,只会发生在我的家用笔记本电脑上。

安装应用程序时没有任何问题,但如果能够看到布局更改而无需一遍又一遍地安装应用程序,那就太好了。

编辑

每当我在布局文件中使用自定义视图时,我也会收到这些消息:

error!
UnsupportedClassVersionError: Bad version number in .class file
Unable to resolve drawable "C:\Users\Me\MyApp\res\drawable-hdpi\logo_text.png" in attribute "src"
Exception details are logged in Window > Show View > Error Log

I've been having this problem for a while:

Here is my header.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical">


<ImageView android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:src="@drawable/logo_text"/>

</LinearLayout>

And this what the Eclipse/Android XML viewer is giving me:

Unable to resolve drawable "C:\Users\Me\MyApp\res\drawable-hdpi\logo_text.png" in attribute "src"

This happens in other projects as well for seemingly random images. Project->Clean doesn't help either. I know this has to be an issue with my machine or eclipse installation because it doesn't happen on my work machine, only my home laptop.

There are no problems when the app is installed, but it would be nice to be able to see layout changes without having to install the app over and over again.

EDIT

I also get these messages anytime I use a custom View in a layout file:

error!
UnsupportedClassVersionError: Bad version number in .class file
Unable to resolve drawable "C:\Users\Me\MyApp\res\drawable-hdpi\logo_text.png" in attribute "src"
Exception details are logged in Window > Show View > Error Log

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

残月升风 2024-12-04 22:30:50

当我将新图像导入到我的项目中时,有时会遇到这样奇怪的问题。您是否还有其他包含该文件不同版本的 res-image 目录?您可以尝试删除 png 并重新添加到项目中。

I sometimes have weird issues like this when importing new images into my project. Do you have any other res-image directories with different versions of this file? You may try removing the png and re-adding to the project.

你的呼吸 2024-12-04 22:30:50

错误消息明确提到了可绘制目录的 -hdpi 版本。您是否在所有不同版本的可绘制目录中都获得了该图像?也许它在 res/drawable-ldpi 或 res/drawable-mdpi 中,但不在 res/drawable-hdpi 中?

如果您还没有,您可以创建一个普通的 res/drawable 文件夹并在其中添加图像,然后人们会期望系统在找不到特定于定义的版本时回退到该文件夹​​。

The error message explicitly mentions the -hdpi version of the drawable directory. Have you got that image in all of the different versions of the drawable directory? Perhaps it is in res/drawable-ldpi or res/drawable-mdpi but not res/drawable-hdpi?

If you don't already have one, you could create a plain res/drawable folder and add the image there, then one would expect the system to fall back to that whenever it didn't find a definition-specific version.

乖乖兔^ω^ 2024-12-04 22:30:50

实际上尝试在 ImageView 上放置一个 id 标签: android:id=:"@+id/imageView"。告诉我它是否有效。

Actually try to put an id tag on ImageView : android:id=:"@+id/imageView".Tell me if it is working or not.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文