如何保持向后兼容性,同时利用Android的API 15级?兼容性、Android、API

2023-09-06 13:36:39 作者:心会发光亦会发慌

冰淇淋三明治推出了很多全新的UI设计元素,但市场渗透率仍然仅为4%左右。如果一个人想满足未来的应用程序,并利用一些与蜂窝/冰淇淋三明治推出的设计元素,如操作栏,配色方案等,这将是最好的方式,以确保您能够向下的一些点点兼容性如何?

Ice cream sandwich introduced a lot of new UI design elements but market penetration is still only 4% or so. If one wanted to future-proof their application and utilise some of the design elements introduced with Honeycomb/Ice Cream Sandwich, such as the action bar, the colour scheme etc., what would be the best way to ensure you maintain some modicum of backwards compatibility?

推荐答案

虽然我同意@Ollie C,我觉得还有其他选择添加其他比只使用了动作条福尔摩斯库,而说这句话的我积极参与ABS社区,并同意它是 fantasmagoricly 真正有用的,并包含所有UI资产可能会需要。

While I agree with @Ollie C, I think there are other options to add other than just using the Actionbar Sherlock library, while saying this I actively participate in the ABS community and agree it is fantasmagoricly really useful and contains all the UI assets will probably need.

您可以看看UI组件的优雅降级回通过API的水平。因此,例如:

You could look at graceful degradation of UI components back through the API levels. So for example:

您可以创建在文件夹,并设置样式像这样

You could create in the values folder and set the style like so

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="MyAppTheme" parent="@android:style/Theme.Light.NoTitleBar">
        <!-- Any customizations for your app running on pre-3.0 devices here -->
    </style>
</resources> 

然后为Android 3.0+设备,创建值-V11 文件夹:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="MyAppTheme" parent="@android:style/Theme.Holo.Light">
        <!-- Any customizations for your app running on 3.0+ devices here -->
    </style>
</resources>

和为4.0+设备,创建值-V14

And for 4.0+ devices, create values-v14:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="MyAppTheme" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
        <!-- Any customizations for your app running on 4.0+ devices here -->
    </style>
</resources>

REF:http://android-developers.blogspot.co.uk/2012/01/holo-everywhere.html, How使用Holo.Light主题,回落到'光'的pre-蜂窝设备?

也有这个项目:https://github.com/ChristopheVersieux/HoloEverywhere它试图把全息主题。

There is also this project: https://github.com/ChristopheVersieux/HoloEverywhere that it attempting to bring the holo theme.

最后,谷歌鼓励开发者包括来自SDK UI组件,以帮助落后的兼容性问题,而不是直接从Android OS引用它们。虽然这不是你的问题,它确实有助于提供一定的一致性。

Finally; Google encourage the developers to include UI components from the SDK to help with the backward compatibility issue, rather than referencing them directly from the Android OS. While this is not your question, it does help provide some consistency.