2015-12-21 64 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黑暗是動作條的顏色,所以你需要改變這種顏色。 父值是您想要的操作欄主題的類型。