Gunnar Asked: 2020-03-29 14:18:05 +0800 CST 2020-03-29 14:18:05 +0800 CST 2020-03-29 14:18:05 +0800 CST Change color buttons of the AppBar in Android 772 How to change the color of the AppBar buttons? In my case of the back button, the default color is white But mine comes out black and I want to change it to white I tried with the accent colors and it still doesn't change me. android 3 Answers Voted Best Answer x4mp73r 2020-03-29T14:33:19+08:002020-03-29T14:33:19+08:00 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_alphatoabc_ic_ab_back_material Codelaby 2020-10-16T09:46:50+08:002020-10-16T09:46:50+08:00 With the following function it can be applied to any icon in theAppBar 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); } Its use: It is recommended to change the color of the menu items within the AppBarinonCreateOptionsMenu @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); } Jhony Urbano 2020-07-25T17:52:59+08:002020-07-25T17:52:59+08:00 A solution without java code is to modify the xml of stylo. <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> If you have it in Light the back button colors it black, but with DarkActionBar it colors it white
Do it programmatically:
As of API 23 it went from
abc_ic_ab_back_mtrl_am_alpha
toabc_ic_ab_back_material
With the following function it can be applied to any icon in the
AppBar
Its use:
It is recommended to change the color of the menu items within the
AppBar
inonCreateOptionsMenu
A solution without java code is to modify the xml of stylo.
If you have it in Light the back button colors it black, but with DarkActionBar it colors it white