MenuItem light/dark icons in Android 2.x menu

463 views
Skip to first unread message

Matias Hernandez

unread,
Aug 27, 2012, 12:53:47 PM8/27/12
to actionba...@googlegroups.com, Fernando Panizza
Hello there,

I have a question about the icons used for menu items. We've been using ABS for a while (excellent library BTW) and we've encountered the following problem. When building the menu, we assign drawables as icons for the menu items. In Android 4.0 these icons are shown in the action bar and not in the overflow menu, while in 2.x they are shown in the action bar and in the "native overflow" when the menu button is pressed (we don't use the ICS-like overflow button).

The problem occurs when using the Sherlock.Light theme and a Gingerbread device. In that case, the icons drawn in the action bar should be black / dark gray. However, when these options go into the overflow, the menu background is always black (independently of the theme), and the icon is therefore only faintly visible.

The question is: is there a way to fix this? At design theme we're not sure which icons will go where (since it depends on the device's width in dp). A possible workaround that we've considered is to modify the MenuBuilder.bindNativeOverflow() method in ABS to switch the icon (having previously added a "setOverflowIcon()" method or somesuch to MenuItem/MenuItemImpl), as we then know that the action will be drawn in the secondary menu. But I wondered if there is another (more reasonable) solution for this?

Best regards, and thanks for any responses,
- Matías

Jake Wharton

unread,
Sep 19, 2012, 2:22:28 PM9/19/12
to actionba...@googlegroups.com, Fernando Panizza
There's no way to control this, sadly. Filed for the future: https://github.com/JakeWharton/ActionBarSherlock/issues/627

---
Jake Wharton
http://about.me/jakewharton

Matias Hernandez

unread,
Sep 19, 2012, 2:30:09 PM9/19/12
to actionba...@googlegroups.com, Fernando Panizza
Since our menus are built at runtime and not in xml files, we managed to "solve" this by adding the workaround mentioned below (bindNativeOverflow() uses a different icon, set in the MenuItem, which is always the white version).

It's not pretty, but it worked.

Best regards,
- Matias
Reply all
Reply to author
Forward
0 new messages