0

Я хочу знать Как изменить цвет фона панели действий на тему AppCompat. Мой код стилей файл нижеКак изменить цвет ActionBar на AppCompat

Values ​​/ Стили

<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="Theme.AppCompat.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. 
     --> 
    </style> 

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

</resources> 

Значения-V11

<resources> 

    <!-- 
     Base application theme for API 11+. This theme completely replaces 
     AppBaseTheme from res/values/styles.xml on API 11+ devices. 
    --> 
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light"> 
     <!-- API 11 theme customizations can go here. --> 
    </style> 

</resources> 

Values-v14 
<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="Theme.AppCompat.Light.DarkActionBar"> 
     <!-- API 14 theme customizations can go here. --> 
    </style> 


</resources> 

ответ

0

Вы должны быть в состоянии определить colorPrimary в AppTheme:

<style name="AppTheme" parent="AppBaseTheme"> 
    <item name="colorPrimary">#3f51b5</item> 
</style> 
1

андроид exlains, как сделать это http://developer.android.com/training/basics/actionbar/styling.html

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <!-- the theme applied to the application or activity --> 
    <style name="CustomActionBarTheme" 
      parent="@style/Theme.AppCompat.Light.DarkActionBar"> 
     <item name="android:actionBarStyle">@style/MyActionBar</item> 

     <!-- Support library compatibility --> 
     <item name="actionBarStyle">@style/MyActionBar</item> 
    </style> 

    <!-- ActionBar styles --> 
    <style name="MyActionBar" 
      parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse"> 
     <item name="android:background">@drawable/actionbar_background</item> 

     <!-- Support library compatibility --> 
     <item name="background">@drawable/actionbar_background</item> 
    </style> 
</resources> 

, а затем изменить тему в вашем манифесте на тему, которую вы написали выше

+0

Хотя ссылка хороший, пожалуйста, ответьте на вопрос в своем ответе. Не просто укажите ссылку на сайт с третьей стороной. – CommonsWare

Смежные вопросы