的Andr​​oid如何实现从材料设计文档底片 [英] Android How to implement Bottom Sheet from Material Design docs

查看:137
本文介绍了的Andr​​oid如何实现从材料设计文档底片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何实现下片specficiation? <一href="http://www.google.com/design/spec/components/bottom-sheets.html">http://www.google.com/design/spec/components/bottom-sheets.html

How do you implement the bottom sheet specficiation? http://www.google.com/design/spec/components/bottom-sheets.html

新的更新,谷歌驱动器显示这与浮动操作按钮preSS - >

The new update to Google Drive shows this with the Floating Action Button press ->

授予的规范从来不说有关圆角的东西,不管它是可以做到的,只是不知道应该如何去做。目前使用AppCompat库和目标设置为21。

Granted the specs never say anything about rounded corners, regardless it is possible to do, just unsure of how to go about it. Currently using the AppCompat library and target set to 21.

感谢

推荐答案

不幸的是目前关于如何做到这一点(至少没有我知道的),没有官方的方式。
幸运的是有一个库名为BottomSheet(点击)它模仿的外观和感觉 BottomSheet 和支持的Andr​​oid 2.1及更高版本。

Unfortunately there's currently no "official" way on how to do this (at least none that I'm aware of).
Luckily there's a library called "BottomSheet" (click) which mimics the look and feel of the BottomSheet and supports Android 2.1 and up.

在情况下,驱动程序的,这里是如何的code看起来像这个库:

In case of the Drive app, here's how the code would look like with this library:

    new BottomSheet.Builder(this, R.style.BottomSheet_Dialog)
            .title("New")
            .grid() // <-- important part
            .sheet(R.menu.menu_bottom_sheet)
            .listener(new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            // TODO
        }
    }).show();

menu_bottom_sheet (基本上是一个标准的/res/menu/*.xml资源)

menu_bottom_sheet (basically a standard /res/menu/*.xml resource)

<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/folder"
        android:title="Folder"
        android:icon="@drawable/ic_action_folder" />
    <item
        android:id="@+id/upload"
        android:title="Upload"
        android:icon="@drawable/ic_action_file_upload" />
    <item
        android:id="@+id/scan"
        android:title="Scan"
        android:icon="@drawable/ic_action_camera_alt" />
</menu>


输出结果如下:


Output looks like this:

其中,我认为,来自pretty的接近原始。如果你不愉快的颜色,你可以自定义 - 。看到这个(点击)

Which, I think, comes pretty close to the original. If you're not happy with the colors you can customize it - see this (click).

这篇关于的Andr​​oid如何实现从材料设计文档底片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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