我正在尝试将我的应用ActionBar
颜色更改为不成功。我正在使用此库https://github.com/neokree/MaterialNavigationDrawer;
这是style.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:actionBarStyle">@style/AppTheme.ActionBar</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">@style/AppTheme.ActionBar</item>
<item name="colorControlActivated">@color/color_c</item>
<item name="toolbarStyle">@style/Widget.Toolbar</item>
</style>
<style name="Widget.Toolbar" parent="@style/Widget.AppCompat.Toolbar">
<item name="contentInsetStart">5dp</item>
</style>
<style name="AppTheme.ActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">@color/color_a</item>
<item name="background">@color/color_a</item>
<!-- Support library compatibility -->
</style>
<style name="FullscreenTheme" parent="android:Theme.NoTitleBar">
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@null</item>
</style>
<style name="MyNavigationDrawerTheme" parent="MaterialNavigationDrawerTheme.Light.DarkActionBar">
<item name="colorPrimary">@color/color_a</item>
<item name="colorPrimaryDark">@color/color_a</item>
<item name="colorAccent">#FFFFFF</item>
<item name="rippleBackport">true</item>
<item name="singleAccount">true</item>
<item name="multipaneSupport">true</item>
<!--<item name="learningPattern">false</item>-->
</style>
<style name="MySubheaderTheme">
<item name="subheaderTitleColor">#000000</item>
</style>
<style name="MySectionTheme" >
<item name="sectionColorIcon">#000000</item>
<item name="sectionColorText">#000000</item>
<item name="sectionColorNotification">#000000</item>
<item name="sectionBackgroundColorPressed">#160000FF</item>
<item name="sectionBackgroundColorSelected">#0A0000FF</item>
<item name="sectionBackgroundColor">#000000FF</item>
</style>
</resources>
我将MyNavigationDrawerTheme
主题用于我的活动。
答案 0 :(得分:0)
您应该可以使用android:colorPrimary
属性设置操作栏颜色:
<resources>
<!-- inherit from the material theme -->
<style name="AppTheme" parent="android:Theme.Material">
<!-- Main theme colors -->
<!-- your app branding color for the app bar -->
<item name="android:colorPrimary">@color/primary</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<!-- theme UI controls like checkboxes and text fields -->
<item name="android:colorAccent">@color/accent</item>
</style>
</resources>
基于信息here
答案 1 :(得分:0)
您还应该为v21及更高版本创建样式并进行少量更改(因为它们原生支持材质主题)。
在values-v21 / style.xml中,为您的样式添加android:colorPrimary
和其他带有android:
前缀的属性:
<style name="MyNavigationDrawerTheme" parent="MaterialNavigationDrawerTheme.Light.DarkActionBar">
<item name="android:colorPrimary">@color/color_a</item>
<item name="android:colorPrimaryDark">@color/color_a</item>
<item name="android:colorAccent">#FFFFFF</item>
<!--...-->
</style>