gpt4 book ai didi

android - 使用 ShareActionProvider-v7 的 ActionBar 上的 ShareAction 图标大小问题

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:06:48 24 4
gpt4 key购买 nike

我在我的 ActionBar 上解决我的旧 ShareAction,自从我在 SDK Manager 上更新我的包后它就开始工作了。我看到了this来自 Google 的文档说,

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

我添加了相同的内容,但没有添加任何图标:

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

我正在使用:

app:actionProviderClass="Mypackagename.ShareActionProvider"

使用自定义ShareActionProvider,代码如下。你可以看到它here .

我看到了一个 hack 或技巧(使用 ShareActionProvider-v4),一切都很好,因为我决定使用 android.support.v7.widget.ShareActionProvider.

所以,这是我当前的代码:

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

我没有使用 Icon 因为 here医生说,

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.

这是我到目前为止所做的:

 @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;
}

所以,我现在在 Android Studio 1.5.1 中看到的是,

enter image description here

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

enter image description here

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


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

enter image description here

这是编译后的样子:

enter image description here

没有任何变化!

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

Intent.createChooser 也不起作用:来自:https://stackoverflow.com/a/34797718/4409113

编辑:

最有趣的部分是,我刚刚在以下类(class)和他们称之为 SunShine Google 的相同设计和相同结果em> 应用:

Applink

类(class):

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

最佳答案

好的,作为 this post 的 ianhanniballake说,

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.

顺便说一下,我刚刚向 code.google.com 发布了一个问题/报告,您可以在这里看到它:

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

似乎默认图标是 24dp x 24dp 但它应该是这样的:

enter image description here

但是现在,是这样的:

enter image description here

似乎是一个错误,仍在等待接受或回答。如果他们回答,我会更新这篇文章。7 天过去了!

更新:

最后,他们已将缺陷分配给开发团队,他们将在获得更多信息时更新此问题。

非常感谢 ssingamc...@google.comGoogle 的支持。

这里有答案:http://code.google.com/p/android/issues/detail?id=200335#c10

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

更新: 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

关于android - 使用 ShareActionProvider-v7 的 ActionBar 上的 ShareAction 图标大小问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34995278/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com