有没有办法根据安装应用程序的 SDK 版本来使用不同的主题?
我问的原因是因为我想一直支持到 SDK 版本 8,但是对于那些拥有 ICS 的用户,我希望能够遵循 ICS 的设计标准并使用 Holo 主题。
我可以从Program different layouts for different versions in android中看到,我可以有一个文件夹 values-v14 ,它将有一个 theme.xml 来覆盖主题声明。但是,如果我引用 Theme.Holo,它将无法编译。我相信这是因为我的 AndroidManifest.xml 中有以下内容
<uses-sdk android:minSdkVersion="8" />
<uses-sdk android:targetSdkVersion="11"/>
任何指针将不胜感激。
更新:-好的,这是我的文件:- AndroidManifest.xml:
<application
android:icon="@drawable/icon"
android:label="@string/app_name"
android:name=".Refunder"
android:theme="@style/MainTheme"
>
res/values/themes.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MainTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:typeface">normal</item>
<item name="android:textSize">15sp</item>
</style>
</resources>
res/values-v11/themes.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MainTheme" parent="@android:style/Theme.Holo">
<item name="android:typeface">normal</item>
<item name="android:textSize">15sp</item>
</style>
</resources>
这与我在这里阅读的文章一致:- http://android-developers.blogspot.com/2012/01/holo-everywhere.html
当我这样做时,我在 Eclipse 中得到一个编译错误,说: -
error: Error retrieving parent for item: No resource found that matches the given name '@android:style/Theme.Holo'