跨平台的 Android 选项卡外观是否正确?
我正在编写一个需要在各种 Android 设备上运行的应用程序,每个设备都有自己特定于运营商的主题。
不幸的是,存在一个问题,即每个设备的选项卡主题不兼容——普通 Android 对所选选项卡使用浅色背景、深色前景,但 HTC Desire 使用深色背景、浅色前景,这意味着图标专为一个人看起来不对而设计。 (此外,HTC Desire 的主题有一个错误,他们忘记为选定的选项卡设置前景色,这意味着你实际得到的是深色背景、深色前景。系统应用程序似乎都手动设置前景,但我在几个用户应用程序中观察到了这一点。)
因此,为了使应用程序在所有设备上看起来都正确,我认为我有两个真正的选择:
完全自定义我的选项卡主题,这样我们就不会依赖系统主题完全
其他
我不想做第一个,因为这就是为什么我们的应用程序不会'与设备上的其他应用程序不匹配。但除非有一个聪明的方法来解决这个问题,否则我就必须这么做。有什么建议吗?我不可能是第一个遇到这种情况的人。例如,有什么方法可以让 Android 自动更改图标的颜色吗?
(此外,还有一个问题我仍在解决,那就是系统应用程序似乎显示与用户应用程序不同的选项卡:一定有一些我还没有找到的主题设置,但在搜索源代码后没有任何迹象对此表示赞赏。)
I'm writing an application that needs to work on a variety of Android devices, each with their own carrier-specific themeing.
Unfortunately, there's a problem in that the tab themes for each device are incompatible --- stock Android uses light-background, dark-foreground for the selected tab, but the HTC Desire uses dark-background, light-foreground, which means that icons designed for one look wrong on the other. (Also, the HTC Desire's themes has a bug where they've forgotten to set the foreground colour for selected tabs, which means what you actually get is dark-background, dark-foreground. The system applications all appear to set the foreground manually, but I've observed this in several user applications.)
So, in order to make the application look right on all devices, I figure that I have two real options:
completely customise my tab theme so we don't rely on the system theme at all
other
I'd rather not do the first because that why our application won't match the other applications on the device. But unless there's a clever way around this issue, that's what I'll have to do. Any suggestions? I can't be the first person to come across this. Is there, for example, any way to make Android change the colour of the icons automatically?
(In addition, there's an issue I'm still working on which is that system applications appear to display tabs different to user applications: there must be some theme setting somewhere I haven't found yet, but after scouring the source code there's no sign of it. Pointers appreciated.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想支持所有 Android 版本(1.5+),第一个选项是最简单的解决方案。
系统应用程序(例如联系人应用程序)使用自定义选项卡。看看这里:
https://android.googlesource.com/platform/packages/apps/Contacts
(例如,在这些文件夹中搜索“tab_”:res/layout-finger、res/drawable-finger、res/drawable-hdpi-finger)
If you want to support all Android versions (1.5+), the first option is the easiest solution.
The system applications (e.g. Contacts app) use custom tabs. Take a look here:
https://android.googlesource.com/platform/packages/apps/Contacts
(e.g. search for "tab_" in these folders: res/layout-finger, res/drawable-finger, res/drawable-hdpi-finger)