我正在尝试设置图标 ShareActionProvider,需要一个纯白色而不是半透明的白色。
但是 share_menu.xml 和代码中的设置不起作用。只是想知道在扩展 ShareActionProvider 之前是否有人有解决方法。(我正在使用 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" />
更新:也尝试将其设置为样式,但没有乐趣
<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>