Size of ShareAction icon issue on ActionBar with ShareActionProvider-v7

本小妞迷上赌 提交于 2019-12-01 03:16:49
ʍѳђઽ૯ท

Okay, As ianhanniballake at this post said,

Icons in material design are 24dp x 24dp, as properly reflected by the SearchView. However, ShareActionProvider has not yet been updated to material design by default.

By the way, i've just posted a question/report to code.google.com which you can see it here:

http://code.google.com/p/android/issues/detail?id=200335

It seems that default icon is 24dp x 24dp but it should be like this:

But now, it is like this:

Seems to be a bug and still waiting for accepting or answering about it.I'll update this post if they answered.7 days passed!

UPDATE:

Finally, they've assigned the defect on to the development team and they will update this issue with more information as it becomes available.

Big thanks to ssingamc...@google.com at Google for support.

The answer is available here: http://code.google.com/p/android/issues/detail?id=200335#c10

I will update this answer if any updates or any fixes was available.

UPDATE: http://code.google.com/p/android/issues/detail?id=200335#c12

Hi, The development team has fixed the issue that you have reported and it will be available in a future build. Thanks

Harshad

Icons in material design are 24dp x 24dp, as properly reflected by the SearchView. However, ShareActionProvider has not yet been updated to material design by default.

You can set actionModeShareDrawable in your theme to set the share icon in the ShareActionProvider:

<item name="actionModeShareDrawable">@drawable/share_icon</item>

Note that ShareActionProvider is not found anywhere in the material design guidelines and with Android M's Direct Share capability (which requires you use a standard share intent at this time), it is unclear on whether the ShareActionProvider is a suggested pattern any more.

For more detail Visit Here.

AppCompat ShareActionProvider icon is too big compared to other icons

Change the icon Pragmatically

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main_details, menu);
    // Locate MenuItem with ShareActionProvider
    MenuItem item = menu.findItem(R.id.shareac);
    // Fetch and store ShareActionProvider
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    Bundle extra = getIntent().getExtras();
    String title = extra.getString("title");
    Bundle extraurl = getIntent().getExtras();
    String url = extraurl.getString("url");
    shareIntent.putExtra(Intent.EXTRA_TEXT, "Check this new project from something : " + title + url);
    shareIntent.setType("text/plain");
    mShareActionProvider.setShareIntent(shareIntent);
    //Here
    item.setIcon(getResources().getDrawable(R.drawable.ic_share));
    return true;
}

or Theme

<item name="actionModeShareDrawable">@drawable/ic_share</item>
pRaNaY

If you don't need custom icon for share menu item then try android resource for share menuitem as below:

 <item android:id="@+id/action_share"
   android:title="@string/share"
   app:showAsAction="ifRoom"
   android:icon="@android:drawable/ic_share"
   app:actionProviderClass="android.support.v7.widget.ShareActionProvider"/>

See here

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!