的minSdkVersion = 7 TargetSDKVersion = 17Android:如何針對不同的Android版本使用不同的主題?
如果用戶具有SDKVersion 11或更高我喜歡設置主題Theme.Holo.Light。 它在這裏不適用於我。當我啓動了3.1設備上的應用程序,它只是使用了Theme.Light:
同樣的,當我在設備上運行此應用程式版本低於3.1
我Folderstructure:
清單:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/MyTheme" >
個
值-V11:
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="@android:style/Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="@android:style/Theme.Light">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
<!-- Any customizations for your app running on devices with Theme.Holo here -->
</style>
其它數值的文件夾:
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="@android:style/Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="@android:style/Theme.Light">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="MyTheme" parent="@android:style/Theme.Light">
<!-- Any customizations for your app running on devices with Theme.Holo here -->
</style>
我該如何正確使用它?
真誠 馬爾科Seiz
我這樣做,但它仍然顯示舊的主題,而不是我的Android 4.1和3.1設備 –
上的全息主題你刪除重複? – Ahmad
是的,我做到了。我找出了錯誤。我必須爲一種語言創建兩個文件夾。對於德語:values-de和values-de-v11和英語相同......現在可以運行:)感謝您的幫助和提示! –