ShareActionProvider 外观
ShareActionProvider appearance
我的 ActionBar 中有 android.support.v7.widget.ShareActionProvider
菜单。
当我点击 "Share" 时,应用程序列表显示为弹出菜单。
当我在 Google Play Newsstand 中单击 "Share" 时,应用列表显示为底部 sheet 可以拉起。
我们可以将 ShareActionProvider
从 appcompat-v7
配置为显示底部 sheet 而不是弹出菜单吗? ShareActionProvider
周围是否有底部 sheet 的替代方案?
我找到了一个库 https://github.com/soarcn/BottomSheet。它给出了如何重新实现底部 sheet 的 ShareActionProvider 的想法。不幸的是,目前似乎缺少该库 'swipe up to pull up'。更重要的是,我仍然需要解决意图,处理屏幕旋转并支持所有 Android 版本......这不应该包含在 appcompat-v7
中吗?
解决方案是使用 Intent.createChooser
而不是 ShareActionProvider
。
它提供的体验与在 Android 5.0 上分享来自 Google 报亭的文章完全相同。
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, ...);
shareIntent.setType("text/plain");
startActivity(Intent.createChooser(shareIntent, getString(R.string.item_share)));
我的 ActionBar 中有 android.support.v7.widget.ShareActionProvider
菜单。
当我点击 "Share" 时,应用程序列表显示为弹出菜单。
当我在 Google Play Newsstand 中单击 "Share" 时,应用列表显示为底部 sheet 可以拉起。
我们可以将 ShareActionProvider
从 appcompat-v7
配置为显示底部 sheet 而不是弹出菜单吗? ShareActionProvider
周围是否有底部 sheet 的替代方案?
我找到了一个库 https://github.com/soarcn/BottomSheet。它给出了如何重新实现底部 sheet 的 ShareActionProvider 的想法。不幸的是,目前似乎缺少该库 'swipe up to pull up'。更重要的是,我仍然需要解决意图,处理屏幕旋转并支持所有 Android 版本......这不应该包含在 appcompat-v7
中吗?
解决方案是使用 Intent.createChooser
而不是 ShareActionProvider
。
它提供的体验与在 Android 5.0 上分享来自 Google 报亭的文章完全相同。
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, ...);
shareIntent.setType("text/plain");
startActivity(Intent.createChooser(shareIntent, getString(R.string.item_share)));