android - Performance improvements to tint menu icons -
i want tint menu icons, visible ones 1 color , ones in overflow menu different color. wrote following code:
final menubuilder builder = getmenubuilder(menu); if (builder != null) { builder.flagactionitems(); final arraylist<menuitemimpl> items = builder.getvisibleitems(); (int = 0, size = items.size(); < size; ++i) { final menuitemimpl item = items.get(i); final drawable icon = item.geticon(); if (icon != null) { final drawable mutate = icon.mutate(); if (item.isactionbutton()) { mutate.setcolorfilter(actionitemcolor, porterduff.mode.src_atop); } else { mutate.setcolorfilter(color, porterduff.mode.src_atop); } item.seticon(mutate); } } }
this code works not pleased performance, since started using vector drawables. here measurement of 3 vector icons, thee icons visible directly. call flagactionitems() takes 160ms... seems bit much.
does have idea how improve performance. code needs work on android 4.2 , newer.
Comments
Post a Comment