android - Android SDK 1.5和2.0在渲染方面有什么区别?

标签 android layout emulation

我即将完成 Android 应用程序的开发。但似乎有一个问题。当我开始处理该项目时,我仅使用默认的 1.5 设备分辨率,即 320x480。但现在当我处于测试阶段时,我开始在 1.5 和 2.0 中以 480x800 和 480x854 进行测试。这些分辨率未在 1.5 AVD 管理器中定义,因此我使用提供的工具来创建自己的分辨率。我设置了分辨率加上新的 dpi(大显示器为 240,小显示器为 16o)。这就是我测试完所有内容后发生的情况。

在 1.5 中,当我将常量设置为高分辨率并使用特定 AVD 运行应用程序时,我得到了成比例且对齐良好的组件,但图像具有相同的分辨率,文本字体也保持其大小。当然,整个布局会拉伸(stretch),所以现在我的 ListActivity 中有更长的行。

另一方面,在 2.0 中,我根本没有对常量进行任何更改。但情况是应用程序的外观保持不变。图像被拉伸(stretch)以适应新扩展的容器,但一切看起来都像我开发应用程序的原始分辨率,只是更大。

我的问题是为什么以及如何发生这种情况? 2.0在布局上有一些修改,但它们到底是什么?如何让我的应用程序在 1.5 中看起来与 2.0 中一样?

这种情况我很难描述,而且由于法律问题我无法发布任何屏幕截图。因此,如果您需要任何说明,请随时询问。感谢所有帮助。谢谢。

附注当我指的是测试时,我指的是仅在模拟器上。尚未使用过真实设备。

最佳答案

引用我自己的话:

If your application is compiled for Android 1.5 or lower, Android will assume your application was designed to look good on the classic screen size and resolution. Android will then automatically do the following:

  • If your application is installed on a device with a larger screen, Android will run your application in "compatibility mode", scaling everything based on the actual screen size. So, suppose you have a 24px square PNG file, and Android install and runs your application on a device with the standard physical size but a WVGA resolution (a so-called "high-density" screen). Android might scale your PNG file to be 36px when it displays it, so it will take up the same visible space on the screen. On the plus side, Android handles this automatically; on the minus side, bitmap scaling algorithms tend to make the images a bit fuzzy.
  • Android will block your application from running on a device with a smaller screen. Hence, QVGA devices, like the HTC Tattoo, will be unable to get your application, even if it is available on the Android Market.

If your application is compiled for Android 1.6 or higher, Android assumes that you are properly handling all screen sizes, and therefore will not run your application in "compatibility mode".

我建议您阅读以下内容:

(注意:AndroidGuys 链接可能加载有点慢 - 他们的网站出现了一些问题)

引用的段落来自上面第三个项目符号项目。

关于android - Android SDK 1.5和2.0在渲染方面有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2364677/

相关文章:

java - 2022年如何应对后台地理围栏?

android - WorkManager 谷歌 API : wait 15 minutes for every periodic worker execution?

android - Android 上的底栏

javascript - 如何模拟文本字段(或其他输入字段)的按键并让浏览器执行该按键的默认操作

c# - 使用 wpf : click, 拖动、输入、退出进行完全鼠标控制模拟

android - 如何使用 Jetpack compose 实现交错网格布局?

android - recyclerview 的所有版本在哪里?

ruby-on-rails - 我可以在没有 Controller 的情况下直接从 routes.rb 渲染布局吗?

css - 创建div布局

assembly - 对模拟器进行编程 : How does the emulator understand opcodes from addresses?