布局不规则的 Android HDPI 设备

发布于 2024-12-12 00:43:38 字数 655 浏览 0 评论 0原文

我遇到越来越多布局不规则的 Android 设备,尤其是在 HDPI 部分。

问题是,即使我只在 xml 布局中使用 DIP 值,我的更复杂的布局也无法正确缩放。由于我在 TransformAnimation 代码中使用浮点值,因此动画尤其有问题。

例如,我将拥有一部 240dpi 的手机,屏幕为 3.7 英寸,采用 Android 标准分辨率。我可以为该设备制作 HDPI 和大型布局,并让它们完美契合所有设计和美学。

然后我有一个4.2英寸的手机,但它的垂直分辨率仍然低于XHDPI或XLARGE。如果您询问设备的 DPI 是多少,它也会报告 240dpi。不幸的是,由于实际不同的宽高比、实际不同的屏幕尺寸和实际不同的分辨率,我的布局无法正确缩放。也没有办法制作一个单独的布局文件夹,因为设备认为它是一个大布局和 hdpi,因为它只是报告错误。 (两个EVO,其他几个“长”手机)阅读android文档似乎你可以使用layout-long-large和一些其他类型的组合,但手机本身仍然认为它只是布局大的。 long 限定符确实适用于报告其自身正确信息的设备。

人们如何使用 Android 框架来处理这个问题,而不用代码来处理。这对我来说将是一项非常乏味的工作,而且我对如果硬件错误地报告有关其自身的所有信息如何动态地执行此操作有疑问。

洞察力受到赞赏。

I am encounter more and more android devices with irregular layouts, especially in the HDPI section.

The problem is that my more complex layouts do not scale correctly even though I only use DIP values in my xml layouts. Animations are particularly problematic since I use float values within the TransformAnimation code.

For instance, I will have a 240dpi phone with a 3.7 inch screen, with android standard resolutions. I can make HDPI and large layouts for this device and have them fit all designs and aesthetics perfectly.

Then I have a phone with a 4.2inch, but its vertical resolution is still less than XHDPI or XLARGE. If you ask the device what its DPI is, it will report 240dpi as well. Unfortunately due to the actually different aspect ratio, actually different screen size and actually different resolution, my layouts do not scale correctly. There is also no way to make a separate layout folder because the device THINKS it is a layout-large and hdpi, because it simply reports it wrong. (Both EVOs, several other "long" phones) Reading the android documentation it seems like you could use layout-long-large and some other kind of combination, but the phone itself still thinks it is only layout large. the long qualifier does work in devices that report proper information about itself.

How do people deal with this with the Android framework, without doing it in code. That would be a very tedious work around for me, and I have questions about how dynamically I could do that if the hardware reports all information about itself incorrectly.

Insight appreciated.

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

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

发布评论

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

评论(3

单调的奢华 2024-12-19 00:43:38

你的目标框架是什么?我认为,除非 API 目标为 9 或更高,否则设备不会将自身报告为 xhdpi。

What is your target framework? The device won't report itself as xhdpi unless the API target is 9 or above, I think.

︶ ̄淡然 2024-12-19 00:43:38

解决这个问题的一种方法是每次应用程序启动时都会将其用户代理发送到服务器。然后,服务器确定要使用的正确图像,并将该信息发送到使用它来显示该图像的客户端。其他移动平台也出现过这种情况,尽管 Android 解决了这个问题,但您似乎遇到了问题。试试这个。

您还考虑过使用 9 路径图像吗?

One way to address this, is everytime the app starts it sends its useragent to server. The server then determines the correct image to use, and send that info to client that uses it to display the that image. This has been the case in other mobile platforms and though Android addresses it you seem to have problems with it. Ttry this out.

Also have you considered using 9-path images?

橙味迷妹 2024-12-19 00:43:38

我对这个问题的解决方案是越来越依赖RelativeLayout的定位。

My solution to this problem is to rely on RelativeLayout's positioning more and more.

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