Setting a custom share icon on Actionbar ShareActionProvider

actionbarsherlock, android, shareactionprovider

Solution

When I am looking to customize the action bar, usually the first place I look is the ActionBarSherlock themes and styles.

I found that the Sherlock theme uses the "actionModeShareDrawable" as found in theme.xml file.

Try changing your theme to include the "actionModeShareDrawable" item directly.

<style name="Theme.MyApp" parent="Theme.Sherlock.Light">
    <item name="actionModeShareDrawable">@drawable/ic_action_share</item>
</style>

Problem

I'm trying to set the icon ShareActionProvider, need a solid white one instead of the semi transparent white one. However setting in share_menu.xml and code doesn't work. Just wondering whether anyone has got workaround for this before extending the ShareActionProvider. (I'm using actionbarsherlock) ``` @Override public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) { inflater.inflate(R.menu.share_menu, menu); MenuItem actionItem = menu.findItem(R.id.share_action_provider); ShareActionProvider actionProvider = (ShareActionProvider) actionItem.getActionProvider(); actionProvider.setShareIntent(mShareIntent); // re-setting the icon as it's not being picked up from the menu xml file actionItem.setIcon(R.drawable.ic_action_share); super.onCreateOptionsMenu(menu, inflater); } ``` share_menu.xml ``` <item android:id="@+id/share_action_provider" android:showAsAction="ifRoom" android:title="@string/share_with" android:icon="@drawable/ic_action_share" android:actionProviderClass="com.actionbarsherlock.widget.ShareActionProvider" /> ``` Update: Also tried setting it in the style, but no joy ``` <style name="Theme.MyApp" parent="Theme.Sherlock.Light"> <item name="actionModeStyle">@style/ActionModeStyle</item> <item name="android:actionModeStyle">@style/ActionModeStyle</item> </style> <style name="ActionModeStyle" parent="Widget.Sherlock.ActionMode"> <item name="actionModeShareDrawable">@drawable/ic_action_share</item> </style> ```

Original source