How to change the color of the buttons of the AppBar ?, in my case of the return button, the default color is white
But mine turns black and I want to change it to white try it with the accent colors and even then it does not change me.
Do it programmatically:
final Drawable upArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
upArrow.setColorFilter(Color.parseColor("#FFFFFF"), PorterDuff.Mode.SRC_ATOP);
getSupportActionBar().setHomeAsUpIndicator(upArrow);
As of API 23 it went from abc_ic_ab_back_mtrl_am_alpha
to abc_ic_ab_back_material
With the following function you can apply to any icon of AppBar
public static void tintMenuItemIcon(Context context, Menu menu, int idItem, int color) {
Drawable drawable = menu.findItem(idItem).getIcon();
drawable = DrawableCompat.wrap(drawable);
DrawableCompat.setTint(drawable,color );
menu.findItem(idItem).setIcon(drawable);
}
Use:
It is recommended to change the color of menu items within AppBar
in onCreateOptionsMenu
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_routes, menu);
GeneralUtils.tintMenuItemIcon(getActivity(), menu, R.id.action_sort, Color.WHITE);
GeneralUtils.tintMenuItemIcon(getActivity(), menu, R.id.action_filter, Color.WHITE);
super.onCreateOptionsMenu(menu, inflater);
}
A solution without java code is to modify the stylo xml.
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
If you have it in Light, the button on the back colors it black, but with DarkActionBar it colors it white