Android中的底部共享表

kan*_*idj 6 android share android-intent material-design

在Android应用程序中共享数据时,我看到多个应用程序使用底部工作表(例如Google I/O 2015)来指示要执行操作的应用程序,而不是包含用于处理您的意图的应用程序的标准对话框.

例如:

Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TITLE, "Some title..");
shareIntent.putExtra(Intent.EXTRA_TEXT, "Some text");
startActivity(Intent.createChooser(shareIntent, "Share via.."));
Run Code Online (Sandbox Code Playgroud)

由于操作系统版本选择了选择器的显示,因此无法解决问题.

有任何方法可以更改此代码以获得每个材料设计的Share Bottom表单https://www.google.com/design/spec/components/bottom-sheets.html#bottom-sheets-content在此输入图像描述

有没有人知道第三方库在旧的API版本上做到这一点?

我找到了https://github.com/soarcn/BottomSheet

但这只能让我从底部工作表创建一个菜单.我想在现实中,我可以查找所有可以执行我正在尝试的操作的应用程序,并在此库上手动添加菜单项,但我希望有一些更简单的东西,因为它不是突破性的功能.

Mic*_*ael 15

这是运行Android 6.0的Nexus 5上相同的底页.

这在Android的旧版本或修改版本上可能有所不同.(即三星设备等)


Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "Check out this dope website! - https://mikemiller.design/"); // Simple text and URL to share
sendIntent.setType("text/plain");
this.startActivity(sendIntent);
Run Code Online (Sandbox Code Playgroud)

结果

在此输入图像描述


Zac*_*ers 3

我们的 BottomSheet 实现有一个可供您使用的公共组件,它可以让您为工作表指定意图/过滤器等,并且其行为与 Lollipop 上的系统版本非常相似

https://github.com/flipboard/bottomsheet