简体   繁体   中英

Changing the background color of my ActionBar in android

Good day!

First of all, I've already checked the net on this and applied the suggested solutions. However, it still does not change the bg color of the overflow. The last thread I've checked was this

The answers are very informative especially the one from Jonik. However, I still was not able to change the color of the overflow on my action bar. Here is the code for my theme:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="android:actionBarStyle" tools:ignore="NewApi">@style/Actionbar</item>
    <item name="actionBarStyle">@style/Actionbar</item>
    <item name="drawerArrowStyle">@style/ArrowStyle</item>
    <item name="android:popupMenuStyle">@style/PopupBackground</item>
</style>

<style name="Actionbar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
    <item name="android:background" tools:ignore="NewApi">@color/primary</item>
    <item name="background">@color/primary</item>
</style>

<style name="grrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
    <item name="spinBars">true</item>
    <item name="android:color">@color/white</item>
</style>
  <!-- Customize your overflow here. -->
<style name="PopupBackground" parent="Widget.AppCompat.ListPopupWindow">
    <item name="android:popupBackground">@color/primary</item>
</style>

The color primary is set to be darkblue. After implementing the code, the overflow still displays a black background instead of the darkblue color and only the action bar is set to have darkblue.

Is there something I'm doing wrong or not noticing? I've been editing this for sometime now and I've implemented most of the suggested solutions that I have found in stack, and from other tutorials. However, I am still unable to change it. Any help or link is much appreciated.

Try this by code programatically

ActionBar ab = getActionBar();
ab.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#0000ff")));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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