在我的应用程序中支持 Android 2.x 平板电脑的最佳方式是什么?
我正在开发一个 Android 应用程序,它绝对需要支持 Android 2.1+ 设备,包括平板电脑和手机。
棘手的部分是我希望能够在 Android 2.x 平板电脑上提供与骨牌 Honeycomb 平板电脑大致相同的用户体验。我计划使用兼容性包,以便片段支持始终可用,但是...
我目前遇到的问题是我购买了 Hannstab 进行测试,并发现它向应用程序报告它有一个“大”屏幕,尽管实际上是 10.1 英寸。从技术上讲,这将使其成为“xlarge”,但当然该类别不包含在 Android 2.2(它运行的)中,因此它是“large”。我最初打算只使用资源限定符并将所有 xlarge 设备视为平板电脑,将其他所有设备视为手机,但现在我意识到我不能这样做。
将所有 xlarge 和 大屏幕设备视为平板电脑会很糟糕吗?据我了解,这包括 Dell Streaks 和其他 5 至 7 英寸屏幕设备。
有更好的选择吗?我还没有真正了解片段,因此基于片段的解决方案对于了解片段的人来说可能是显而易见的。
我注意到,我在 Hannspad 上安装的应用程序通常使用普通的手机 UI,但 Evernote 除外,它使用特定的平板电脑界面 - 我希望我知道他们是如何做到这一点的。
Android 3.2 中引入的新“最小宽度”资源限定符将通过完全消除通用屏幕尺寸桶来解决这个问题。想必我可以通过编写代码来计算以 dp 为单位的屏幕宽度,然后根据需要向活动添加片段来复制此方法。这明智吗?如果这种工作很痛苦的话我宁愿避免。
干杯
I'm developing an Android app that absolutely needs to support Android 2.1+ devices, including tablets and phones.
The tricky part is I want to be able to provide roughly the same user experience on Android 2.x tablets as on bone fide Honeycomb tablets. I'm planning on using the Compatibility package so that Fragment support is always available, but...
The problem I've got at the moment is I've bought a Hannstab for testing, and discovered that it reports to apps that it has a "large" screen, despite actually being 10.1 inches. This would technically make it "xlarge", but of course that category was not included in Android 2.2 (which it runs), hence it's "large". I originally intended to just use resource qualifiers and treat all xlarge devices as tablets, and everything else as phones but now I realise I can't do that.
Would it be so bad to treat all xlarge and large screened devices as tablets? This would include Dell Streaks and other 5 to 7 inch screen devices as I understand it.
Is there a better alternative? I haven't really got my head around fragments properly yet so a fragments-based solution might be obvious to someone who has.
I've noticed that typically, apps I install on my Hannspad use their normal phone UI, with the exception of Evernote which uses a specific tablet interface - I wish I knew how they'd done that.
The new "Smallest Width" resource qualifier introduced in Android 3.2 would solve this problem by doing away with the generalised screen size buckets altogether. Presumably I could copy this approach by writing code to work out the screen width in dp and then adding fragments to the activity as appropriate. Is that wise? I'd rather avoid that kind of work if it's going to be a pain.
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的问题确实是“对于
-large
和-xlarge
设备使用相同的布局等是否可以”,那当然可以。这当然是我要开始的地方。请记住,设备制造商才是真正决定什么是
-large
的人。如果发现一些制造商创建 5 英寸设备并将其归类为-normal
,我不会感到惊讶,因为他们认为-normal
应用程序在其设备上的运行效果往往比其他设备更好-大型
应用程序。可能使用
-large
/-xlarge
资源。我不知道他们是否使用碎片。就屏幕尺寸而言,片段实际上适用于
-large
/-xlarge
UI 基本上是一堆-small
/的情况>-正常
大小的用户界面像乐高® 积木一样拼凑在一起。就 Evernote 而言,他们的-large
/-xlarge
UI 不符合该模式,因此他们可能使用也可能没有使用片段。片段为内存管理和配置更改(例如,屏幕旋转)提供了一些其他优势,因此即使您不在主要屏幕尺寸组之间共享片段,您也可以考虑使用片段。
如果可能的话,我会推迟做出这个决定,直到冰淇淋三明治上市,我们开始看看其中一些东西将如何在小屏幕设备上发挥作用。
If your question really is "is it OK to use the same layouts, etc. for
-large
and-xlarge
devices", that certainly can work. It's certainly where I would start.Bear in mind that device manufacturers really are the ones who determine what is
-large
or not. It would not surprise me to find some manufacturers creating 5" devices to categorize them as-normal
, because they feel that-normal
apps tend to work better on their devices than do-large
apps.Probably using
-large
/-xlarge
resources. I don't know if they are using fragments or not.In terms of screen sizes, fragments really are for cases where the
-large
/-xlarge
UIs are basically a bunch of-small
/-normal
sized UIs snapped together like LEGO(R) blocks. In Evernote's case, their-large
/-xlarge
UI does not fit that pattern, so they may or may not have used fragments.Fragments offer some other advantages for memory management and configuration changes (e.g., screen rotation), so you might consider using fragments even if you are not sharing fragments between major groups of screen sizes.
If possible, I would hold off on making that decision until Ice Cream Sandwich ships and we start seeing how some of this stuff will play out on smaller-screen devices.