bay*_*ezy 27 android android-layout android-theme
有没有办法根据安装应用程序的SDK版本使用不同的主题?
我问的原因是因为我希望一直支持SDK版本8,但对于那些拥有ICS的用户,我希望能够遵循ICS的设计标准并使用Holo主题.
我可以从程序中看到android中不同版本的不同布局我可以有一个文件夹值-v14,它将有一个theme.xml来覆盖主题声明.但是,如果我引用Theme.Holo,它将无法编译.我相信这是因为我在AndroidManifest.xml中有以下内容
<uses-sdk android:minSdkVersion="8" />
<uses-sdk android:targetSdkVersion="11"/>
Run Code Online (Sandbox Code Playgroud)
任何指针都将非常感激.
更新: - 好的,这是我的文件: - AndroidManifest.xml:
<application
android:icon="@drawable/icon"
android:label="@string/app_name"
android:name=".Refunder"
android:theme="@style/MainTheme"
>
Run Code Online (Sandbox Code Playgroud)
RES /值/的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>
Run Code Online (Sandbox Code Playgroud)
RES /值-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>
Run Code Online (Sandbox Code Playgroud)
这与我在这里阅读的文章一致: - 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'
Run Code Online (Sandbox Code Playgroud)
Kuf*_*ffs 15
你正在做什么(使用你的values-v14文件夹)是正确的.您只需要更改Build Target以允许它进行编译.(右键单击您的项目,选择属性,选择Android,选择Android 14或更高版本)
确保你没有使用任何超过你的android:minSdkVersion的功能,因为如果在早期版本的Android上使用它会导致强制关闭.
| 归档时间: |
|
| 查看次数: |
18615 次 |
| 最近记录: |