使用 ShareActionProvider-v7 的 ActionBar 上 ShareAction 图标的大小问题 [英] Size of ShareAction icon issue on ActionBar with ShareActionProvider-v7

查看:21
本文介绍了使用 ShareActionProvider-v7 的 ActionBar 上 ShareAction 图标的大小问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理我的 ActionBar 上的旧 ShareAction,自从我在 SDK Manager 上更新了我的包后它就开始工作了.我看到了

如果运行并编译应用程序:

如您所见,ShareAction 的大小太大了.(我猜这违反了 MaterialDesign 指南).

<小时>

我忘了说,我已经尝试过 android:icon="@mipmap/ic_share" ,它与我以前的方法/技巧一起工作.但是,从 AndroidStudio 检查此预览:

这里是编译后:

什么都没变!

那么,我的问题是:这是一个错误还是我在这里做错了什么?

Intent.createChooser 也不起作用:来自:

但现在,是这样的:

似乎是一个错误,仍在等待接受或回答它.如果他们回答,我会更新此帖子.7 天过去了!

更新:

最后,他们已将缺陷分配给开发团队,他们将在可用时更新此问题的更多信息.

非常感谢 Googlessingamc...@google.com 的支持.

答案在此处:http://code.google.com/p/android/issues/detail?id=200335#c10

如果有任何更新或任何修复可用,我会更新此答案.

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

<块引用>

您好,开发团队已修复您报告的问题它将在未来的构建中可用.谢谢

I was working around my old ShareAction on my ActionBar and it was working since I updated my Packages on SDK Manager. I saw this doc from Google which says,

To add a "share" action to your activity, put a ShareActionProvider in the app bar's menu resource. For example:

And I've added the same without adding any Icons:

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

I was using:

app:actionProviderClass="Mypackagename.ShareActionProvider"

With a custom ShareActionProvider with the following code.you can see it here.

I saw a hack or a trick to do that (with ShareActionProvider-v4) and everything was good since I decided to use android.support.v7.widget.ShareActionProvider.

So, Here is my currently code:

<item
   android:id="@+id/shareac"
   android:title="@string/share"
   app:actionProviderClass="android.support.v7.widget.ShareActionProvider"
   app:showAsAction="always" />

I didn't use the Icon because here the doc says,

You do not need to specify an icon, since the ShareActionProvider widget takes care of its own appearance and behavior. However, you do need to specify a title with android:title, in case the action ends up in the overflow menu.

And here is what I've done so far:

 @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);
        return true;
    }

So, here what I see right now in Android Studio 1.5.1 Is,

And if run and compile the app:

As you can see, the size of ShareAction is too much. (It's violating the MaterialDesign guideline I guess).


I forgot to say, I've already tried android:icon="@mipmap/ic_share" which that was working with my previous method/trick. But, check this Preview from AndroidStudio:

And here is after compiled:

Nothing changed!

So, my question: is that a bug or what am I doing wrong here?

Intent.createChooser didn't work also: from: https://stackoverflow.com/a/34797718/4409113

Edit:

The most interesting part, i just saw the same design and the same resutls from Google on the following course and on that app which they've called it SunShine app:

Applink

Course:

https://www.udacity.com//course/viewer#!/c-ud855/l-3961788738/m-4294896397

解决方案

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

这篇关于使用 ShareActionProvider-v7 的 ActionBar 上 ShareAction 图标的大小问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆