hdpi 资源不再加载

发布于 2024-09-12 19:26:05 字数 923 浏览 10 评论 0原文

我正在放大游戏的图形,以便在更高密度的设备上更好地显示。我创建了更高 dpi 的图稿,并将其添加到正确的位置(res/layout/drawable-hdpi)。我在清单中添加了以下内容:

 <supports-screens 
      android:smallScreens="false"
      android:normalScreens="true"
      android:largeScreens="true"
      android:anyDensity="true" />

它工作得很好......除了一张图像我忘记升级并且是从drawable-mdpi中提取的。我放大了该图像,将其放入drawable-hdpi 中并重新启动。现在游戏仅从 mdpi 中提取图像。

我可以使用 git 验证自代码库运行以来我对代码库所做的唯一更改是添加新的图像文件。为了进行故障排除,我尝试删除添加的图像并将 git 存储库重置为工作时的状态。在这两种情况下,它仍然总是从 mdpi 加载。这让我相信这可能是模拟器的问题。我正在我的汽车上网本上开发这个程序,这有时会给我带来模拟器问题(通常需要一个小时左右才能启动,并且在 Atom 上运行得非常非常缓慢)。

有人知道什么可能会阻止游戏从 hdpi 中退出吗?

编辑

经过大量故障排除后,我仍然没有更接近解决这个问题。看来我的应用程序可能正在兼容模式下运行。它不显示“邮票”大小,它使用整个 wvga800 屏幕;但 getDisplayMetrics().密度 返回 1.0。模拟器声明它设置为高(240)dpi,所以我假设密度应该> 1.0。

随机数据点:将drawable-hdpi 目录更改为drawable-large 会导致加载更大的图像。在这种情况下 getDisplayMetrics().密度 仍然是 1.0 所以我无法进行正确的 px->dp 转换。

I'm in the process of up-scaling the graphics for my game for better display on higher density devices. I created the higher dpi artwork, added it to the correct place (res/layout/drawable-hdpi). I added the following to my manifest:

 <supports-screens 
      android:smallScreens="false"
      android:normalScreens="true"
      android:largeScreens="true"
      android:anyDensity="true" />

And it worked beautifully... with the exception of one image I forgot to upscale and was being pulled from drawable-mdpi. I upscaled that image, dropped it into drawable-hdpi and relaunched. Now the game is only pulling images from mdpi.

I can verify with git that the only change i made to the codebase since it was working is adding the new image file. For troubleshooting purposes I've tried both removing that added image and resetting my git repo to the state it was in when it worked. In both cases its still just always loading from mdpi. This leads me to believe it may be an issue with the emulator. I'm developing this in my car on a netbook, which sometimes gives me issues with the emulator (usually takes an hour or so to boot and runs very, very sluggishly on the Atom).

Anyone have an idea as to what might be stopping the game from pulling from hdpi?

Edit

After a lot of troubleshooting I'm still no closer to solving this. It seems my app may be running in compatibility mode. It's not displaying "postage stamp" sized, it's using the whole wvga800 screen; but getDisplayMetrics().density returns 1.0. The emulator states it is set at High (240) dpi, so I'm assuming density should be > 1.0.

Random datapoint: Changing the drawable-hdpi directory to drawable-large causes the larger images to load. In that case getDisplayMetrics().density is still 1.0 so I can't do proper px->dp conversions.

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

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

发布评论

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

评论(2

╰ゝ天使的微笑 2024-09-19 19:26:05

res/layout/drawable-hdpi 不是正确的位置。 res/drawable-hdpi 是正确的位置。

res/layout/drawable-hdpi is not the correct location. res/drawable-hdpi is the correct location.

如此安好 2024-09-19 19:26:05

在这里查看我的问题

Android Eclipse 模拟器问题:运行 WVGA (hdpi)作为mdpi屏幕

我修复它的方法是删除AVD并创建一个新的。我仍在努力寻找问题的具体答案。到目前为止,您所能做的就是重新启动计算机和/或制作新的 AVD。

Check out my problem here

Android Eclipse emulator problem: Runs WVGA(hdpi) as a mdpi screen

The way I fix it is to delete the AVD and create a new one. I'm still trying to find an concrete answer to the problem. So far all you can do is restart the computer and/or make a new AVD.

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