Jon
Jon

Reputation: 29

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.

Upvotes: 1

Views: 386

Answers (1)

Rutvik
Rutvik

Reputation: 137

Try this by code programatically

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

Upvotes: 1

Related Questions