不同的主题不同的Android SDK中的版本 [英] Different Theme for different Android SDK versions
问题描述
有没有一种方法使用一个不同的主题,在其SDK版本的应用程序安装在?这取决于
我想问的原因是因为我想支持所有的方式回到SDK版本8,但对于那些有ICS我希望能够按照设计标准ICS和使用全息主题的用户。
我可以从<一见href="http://stackoverflow.com/questions/8908508/program-different-layouts-for-different-versions-in-android">Program不同的布局不同版本的android系统中,我可以有一个文件夹值,V14,这将有theme.xml覆盖主题的宣言。但是,它不会编译,如果我引用Theme.Holo。我相信这是因为我在AndroidManifest.xml中以下
&LT;使用-SDK安卓的minSdkVersion =8/&GT;
&LT;使用-SDK机器人:targetSdkVersion =11/&GT;
任何指针将是非常美联社preciated。
更新: - OK所以这里是我的文件: - AndroidManifest.xml中:
&lt;应用
机器人:图标=@可绘制/图标
机器人:标签=@字符串/ APP_NAME
机器人:名称=。Refunder
机器人:主题=@风格/ MainTheme
&GT;
RES /价值/的themes.xml:
&LT; XML版本=1.0编码=UTF-8&GT?;
&LT;资源&GT;
&LT;样式名称=MainTheme父=@安卓风格/ Theme.Light.NoTitleBar&GT;
&LT;项目名称=机器人:字体&GT;正常&LT; /项目&GT;
&LT;项目名称=机器人:TEXTSIZE&GT; 15sp&LT; /项目&GT;
&LT; /风格&GT;
&LT; /资源&GT;
RES /值-V11 /的themes.xml:
&LT; XML版本=1.0编码=UTF-8&GT?;
&LT;资源&GT;
&LT;样式名称=MainTheme父=@安卓风格/ Theme.Holo&GT;
&LT;项目名称=机器人:字体&GT;正常&LT; /项目&GT;
&LT;项目名称=机器人:TEXTSIZE&GT; 15sp&LT; /项目&GT;
&LT; /风格&GT;
&LT; /资源&GT;
这是按照文章中,我读到这里: - <一个href="http://android-developers.blogspot.com/2012/01/holo-everywhere.html">http://android-developers.blogspot.com/2012/01/holo-everywhere.html
当我这样做,我得到在Eclipse编译错误说: -
错误:错误检索父项:没有资源的发现,匹配给定的名字'@android:风格/ Theme.Holo
你在做什么(与你的价值观-V14夹)是正确的。你只需要改变你的构建目标,使其能够编译。 (右键点击你的项目,选择属性,选择Android的,Android的选择14或以上)
请确保你没有更多的使用任何功能比你的android:的minSdkVersion,因为它会导致强制关闭,如果使用在Android的早期版本
Is there a way to use a different theme depending on which SDK version the application is installed on?
The reason I ask is because I want to support all the way back to SDK version 8, but for those users that have ICS I want to be able to follow the design standards for ICS and use the Holo theme.
I can see from Program different layouts for different versions in android that I can have a folder values-v14 which will have a theme.xml to override the theme declaration. However, it won't compile if I reference Theme.Holo. I believe this is because I have the following in my AndroidManifest.xml
<uses-sdk android:minSdkVersion="8" />
<uses-sdk android:targetSdkVersion="11"/>
Any pointers would be much appreciated.
UPDATE:- OK so here are my files:- 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>
This is in accordance with the article I read here:- http://android-developers.blogspot.com/2012/01/holo-everywhere.html
When I do this I get a compile error in Eclipse saying that:-
error: Error retrieving parent for item: No resource found that matches the given name '@android:style/Theme.Holo'
What you are doing (with your values-v14 folder) is correct. You just need to change your Build Target to allow it to compile. (right click your project, choose properties, select Android, Choose Android 14 or above)
Make sure you do not use any features greater than your android:minSdkVersion as it will cause a Force Close if used on an earlier version of Android.
这篇关于不同的主题不同的Android SDK中的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!