41

The latest Android Support Library introduced the DrawerLayout to implement the common UX pattern where you slide right or left to show a navigation menu.

What I'd love to have is a vertical DrawerLayout with the same API, that can be pulled down/up from the top/bottom of my layout.

Since 4.2 the old SlidingDrawer has been deprecated and I haven't heard about some new Widget that implements the same functionality.

Can the DrawerLayout be extended somehow to implement the vertical swipe UX pattern? Does google provide some different widget to implement it?

Google Music for instance has something very similar to what I'm looking to implement to pull up the player.

enter image description here

4

3 回答 3

45

我们最近在 Umano 应用程序中实现了这一点并开源:https ://github.com/umano/AndroidSlidingUpPanel

享受。

于 2013-05-31T21:28:41.353 回答
12

Android 支持库现在具有执行此操作的底部工作表行为。

查看此链接了解更多信息https://material.google.com/components/bottom-sheets.html

于 2016-06-24T21:46:02.423 回答
1

如今,使用它更有意义,您可以在https://code.tutsplus.com/articles/how-to-use-bottom-sheets-with-the-design-supportBottomSheetBehavior上找到有关如何设置它的更多信息-图书馆--cms-26031

基本上,你需要设置你的主要内容,和你的滑动内容。这BottomSheetBehavior仅适用于您从底部滑动到顶部的面板。

它的设置非常简单,BottomSheetBehavior甚至可以开箱即用。仅通过编写一个android.support.design.widget.CoordinatorLayout布局,其中包含另一个视图(甚至wrap_content作为参数中的值layout_height),例如LinearLayout像这样的一个:

<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:behavior_hideable="true"
        app:behavior_peekHeight="56dp"
        app:layout_behavior="android.support.design.widget.BottomSheetBehavior">

        <!-- Your content goes here -->

    </LinearLayout>

</android.support.design.widget.CoordinatorLayout>

在我的例子中,我在 a 中扩展了这个布局,Fragment并将它添加到Activity你想要启用SlidingSheetBehavior.

于 2018-08-29T12:06:43.213 回答