2015-12-21 67 views
2

这很奇怪。 我试图改变使用主题的ActionBar的颜色。 下面是我的价值观为styles.xml代码:ActionBar主题被忽略

<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:Theme.Holo.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. 
     --> 
     <item name="android:actionBarStyle">@style/TheActionBarTheme</item> 
    </style> 

    <!-- Application theme. --> 
    <style name="AppTheme" parent="AppBaseTheme"> 
     <!-- All customizations that are NOT specific to a particular API-level can go here. --> 

    </style> 

    <style name="TheActionBarTheme" parent="@android:style/Widget.Holo.Light.ActionBar"> 
     <item name="android:background">#1f1f2f</item> 
    </style> 


</resources> 

而对于styles.xml中值,14:

<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. --> 
     <item name="android:actionBarStyle">@style/TheActionBarTheme</item> 
    </style> 

     <style name="TheActionBarTheme" parent="@android:style/Widget.Holo.Light.ActionBar"> 
     <item name="android:background">#1f1f2f</item> 
    </style> 

</resources> 

我用requestWindowFeature(Window.FEATURE_ACTION_BAR);在MainActivity

但是ActionBar的颜色并没有改变 - 它是标准的。我在哪里搞砸了?

回答

0

我有你的问题,我分享一个XML样式代码给你检查。

<style name="AppTheme1" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <item name="colorPrimary">#693EB4</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
</style> 

在我已经在style.xml动作条新样式此代码示例,在这个colorPrimary小顶栏(状态栏)的颜色和colorPrimary黑暗是动作条的颜色,所以你需要改变这种颜色。 父值是您想要的操作栏主题的类型。