Setting a custom share icon on Actionbar ShareActionProvider

前端 未结 5 567
情书的邮戳
情书的邮戳 2021-01-01 20:28

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

5条回答
  •  孤独总比滥情好
    2021-01-01 20:52

    vivimice's solution is good, but the icon of last used app for sharing becomes hidden too.

    I did custom share icon as a common menu item without any ShareActionProvider, just in onOptionsItemSelected() method used this code:

    Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
    sendIntent.setType("text/plain");
    startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to)));
    

    It creates not a popup menu, but a chooser dialog.

提交回复
热议问题