Android - 不同屏幕分辨率的奇怪行为

发布于 2024-10-01 21:29:52 字数 332 浏览 1 评论 0原文

我在 Android 中遇到屏幕分辨率问题。

当我第一次在 VGA AVD 上运行我的应用程序时,我发现了这个问题,并且应用程序的图像没有占据我期望的屏幕百分比。我尝试在 HVGA 和 QVGA 上运行它,发现它们都占据了完全相同的屏幕百分比,就好像屏幕分辨率相同一样。

事实上,分辨率是相同的:我调试了程序并在调用 onSizeChanged 时检查了宽度和高度,并为所有 AVD 获得了相同的值(320 x 430,或对于宽分辨率为 320 x 483)。我创建了一些 AVD 并手动设置了它们的分辨率,但行为没有改变。

我的活动的内容视图给了我这些错误的解决方案,它是一个继承自 View 的类。

I'm having some problem with screen resolutions in Android.

I found the problem when I first ran my application on a VGA AVD and the application's images did not occupy the % of the screen I was expecting them to. I tried to run it on HVGA and QVGA and found out that they all occupied the exact same % of the screen, as if the screen resolution was the same.

In fact, resolution was the same: I debugged my program and checked the width and height when onSizeChanged was called, and got the same values for all the AVDs (320 x 430, or 320 x 483 for wide resolutions). I created some AVDs and manually set their resolution, but the behavior did not change.

My activity's content view, that is giving me these wrong resolutions, is a class which inherits from View.

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

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

发布评论

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

评论(1

蛮可爱 2024-10-08 21:29:52

我遇到了同样的问题,在 AndroidManifest.xml 中添加“minSdkVersion”解决了它。

I had the same problem, adding a "minSdkVersion" to my AndroidManifest.xml solved it.

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