霍洛主题和API 8主题、API

2023-09-07 23:48:47 作者:时光会咬人

我有一个必须从API 8+支持的应用程序。但我也希望我的应用程序中的全息主题(11+)。我知道这将不支持作为最小的SDK是8。因此,唯一的解决方案是创建2个独立的应用程序之一为8-11,一个是11+。有没有更好的方式来做到这一点?所以,我可以减少双重维护。

I have an app that must be supported from API 8+. But I also like to have my app the holo theme for(11+). I know it won't be supported as the min sdk is 8. So the only solution will be to create 2 separate apps one for 8-11 and one for 11+. Is there any better way to do this? So that I can reduce double maintenance.

推荐答案

有没有必要创建两个单独的应用程序。你只需要创建主题的两个定义为您的应用程序:

There's no need to create two separate apps. You just need to create two definitions of theme for your app:

styles.xml中/ RES /值-V11(将仅在API使用的11 +)

styles.xml in /res/values-v11 (Will be used only on API 11+)

<resources>
    <style name="app_theme" parent="android:Theme.Holo.Light"/>
</resources>

styles.xml中/ RES /值

styles.xml in /res/values

<resources>
    <style name="app_theme" parent="android:Theme.Light"/>
</resources>

然后,它适用于在AndroidManifest.xml中您的应用程序:

and then, apply it to your application in AndroidManifest.xml:

<application
        ...
        android:theme="@style/app_theme"
        >
  ...
</application>

此设置使用资源预选赛。你可以阅读更多关于他们这里 。

This setup uses resource qualifiers. You can read more about them here.