简体   繁体   English

将actionBar主题更改为Holo.Light?

[英]Changing actionBar theme to Holo.Light?

I need some help with changing the actionbar theme. 我需要一些有关更改操作栏主题的帮助。 Currently its holo dark, but i want it to be holo light. 目前它的全黑,但我希望它是全光。 I have set 我已经设定

<style name="ActionBar" parent="android:Theme.Holo.Light">
    <item name="android:actionBarStyle">
        @android:style/Widget.Holo.ActionBar
    </item>        
</style>

in /styles. 在/ styles中。 But then i need to set it somewhere in the android manifest file, but i dont know where. 但是然后我需要将其设置在android清单文件中的某个位置,但是我不知道在哪里。 Cause the action bar is a part of a bigger activity, and the activity has a holo light theme, just not the action bar. 因为操作栏是较大活动的一部分,并且该活动具有光晕主题,而不是操作栏。 Anyone? 任何人?

What is important to know about setting themes is that by default when you create a project there are 3 folders created under Values: values , values-v11 , and values-v14 . 关于设置主题的要知道的重要一点是,默认情况下,在创建项目时,在“值”下创建3个文件夹: valuesvalues-v11values-v14

The first thing one does by default, is to open the styles.xml under the values folder. 默认情况下,第一件事是打开values文件夹下的styles.xml That is where we go wrong. 那就是我们出问题的地方。 See, because there are 3 folders for the value files, the Android System will attempt to load the styles defined on the folder that is appropriate for the current system setup. 请参阅,因为值文件有3个文件夹 ,所以Android系统将尝试加载在适合当前系统设置的文件夹中定义的样式。 That is, if you run the application on a Nexus Running API level 17, the styles loaded will come from values-v14 and NOT from values . 也就是说,如果您在Nexus Running API级别17上运行应用程序,则加载的样式将来自values-v14不是来自values

Therefore, you must edit each styles.xml file under each folder, to ensure that the theme is loaded correctly regardless of the API level. 因此,您必须编辑每个文件夹下的每个styles.xml文件,以确保无论API级别如何都正确加载了主题。

Your styles.xml for values-v14 should look like this: 您的values-v14 styles.xml应该如下所示:

<resources>
<!--
    Base application theme for API 14+. This theme completely replaces
    AppBaseTheme from BOTH res/values/styles.xml and
    res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
    <!-- API 14 theme customizations can go here. -->
</style>
</resources>

I hope that helped. 希望对您有所帮助。

Inside your manifest file, add the attribute android:theme="@style/ActionBar" inside your <activity> tag, if you want the theme to be applied to than one activity only. 如果您希望仅将主题应用于一个活动,则在清单文件中,在<activity>标记内添加属性android:theme="@style/ActionBar"

<activity 
    android:name="YourActivityName"
    android:theme="@style/ActionBar"
/>

If you want the theme to be applied to all the activities in the app, add the attribute inside your <application> tag 如果要将主题应用于应用程序中的所有活动,请在<application>标签内添加属性

<application 
    android:label="YourAppLabel"
    android:theme="@style/ActionBar" 
/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM