Skip to content

Instantly share code, notes, and snippets.

@alorma
Created December 25, 2015 12:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alorma/63bfb73de0f554d31a22 to your computer and use it in GitHub Desktop.
Save alorma/63bfb73de0f554d31a22 to your computer and use it in GitHub Desktop.
public static void colorizeToolbar(Toolbar toolbarView, int toolbarIconsColor) {
for(int i = 0; i < toolbarView.getChildCount(); i++) {
final View v = toolbarView.getChildAt(i);
if(v instanceof ActionMenuView) {
for(int j = 0; j < ((ActionMenuView)v).getChildCount(); j++) {
//Step 2: Changing the color of any ActionMenuViews - icons that
//are not back button, nor text, nor overflow menu icon.
final View innerView = ((ActionMenuView)v).getChildAt(j);
if(innerView instanceof ActionMenuItemView) {
int drawablesCount = ((ActionMenuItemView)innerView).getCompoundDrawables().length;
((ActionMenuItemView) innerView).setTextColor(toolbarIconsColor);
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment