Change Color of the Overflow Button on Actionbar

How do I change the Action Bar Overflow button color

I found another way to do it which does not require replacing the image!

<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="actionBarTheme">@style/AppTheme.ActionBarTheme</item> <!-- used for the back arrow on the action bar -->
</style>

<style name="AppTheme.ActionBarTheme" parent="@style/ThemeOverlay.AppCompat.ActionBar">
<!-- THIS is where you can color the arrow and the overflow button! -->
<item name="colorControlNormal">@color/splash_title</item> <!-- sets the color for the back arrow -->
<item name="actionOverflowButtonStyle">@style/actionOverflowButtonStyle</item> <!-- sets the style for the overflow button -->
</style>

<!-- This style is where you define the tint color of your overflow menu button -->
<style name="actionOverflowButtonStyle" parent="@style/Widget.AppCompat.ActionButton.Overflow">
<item name="android:tint">@color/white</item>
</style>

Change color of the overflow button on ActionBar

You can change the image used for it using the following style declaration.

<style name="MyCustomTheme" parent="style/Theme.Holo">
<item name="android:actionOverflowButtonStyle">@style/MyCustomTheme.OverFlow</item>
</style>

<style name="MyCustomTheme.OverFlow">
<item name="android:src">@drawable/my_overflow_image</item>
</style>

And if you're using ActionBarSherlock, here's how to do it

<style name="MyCustomTheme" parent="style/Theme.Sherlock">
<item name="android:actionOverflowButtonStyle">@style/MyCustomTheme.OverFlow</item>
<item name="actionOverflowButtonStyle">@style/MyCustomTheme.OverFlow</item>
</style>

<style name="MyCustomTheme.OverFlow">
<item name="android:src">@drawable/my_overflow_image</item>
</style>

How to change Action Bar text based button color?

You can change the color of the MenuItem text easily by using SpannableString instead of String

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.your_menu, menu);

int positionOfMenuItem = 0; // or whatever...
MenuItem item = menu.getItem(positionOfMenuItem);
SpannableString s = new SpannableString("My red MenuItem");
s.setSpan(new ForegroundColorSpan(Color.RED), 0, s.length(), 0);
item.setTitle(s);
}

ActionBar up button color change

You can add a ColorFilter to the Drawable to tint it:

        MenuItemCompat.setOnActionExpandListener(searchView,
new MenuItemCompat.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem menuItem) {
mIsSearchViewOpen = true;
ActionBar ab = ((DSActivity) getActivity()).getSupportActionBar();
//Change the ActionBar background color when SearchView is expanded
if (ab != null) {
ab.setDisplayShowHomeEnabled(true);
ab.setDisplayHomeAsUpEnabled(true);
ab.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg_gray_rect));
Drawable drawable = ResourcesCompat.getDrawable(getActivity(), R.drawable.ic_back_arrow, null);
drawable.setColorFilter(new PorterDuffColorFilter(getResources().getColor(R.color.gray), PorterDuff.Mode.SRC_IN));
ab.setHomeAsUpIndicator(drawable);
}
return true;
}
});

How to change color of Toolbar back button in Android?

use this style

<style name="Theme.MyFancyTheme" parent="android:Theme.Holo">
<item name="android:homeAsUpIndicator">@drawable/back_button_image</item>
</style>

Overflow button on toolbar change color

Okay, I think I have the solution:

<!-- Overflow Button Style. -->
<item name="actionOverflowButtonStyle">@style/menuOverflow</item>

As you can see, remove android: before actionOverFlowButtonStyle in your style.

A lot of options with android: is not working pre-lollipop, you can try to remove some of them.



Related Topics



Leave a reply



Submit