最新的Android支持库引入了DrawerLayout来实现常见的UX模式,在这种模式中,您可以向右或向左滑动以显示导航菜单。
我想要的是一个具有相同API的垂直 DrawerLayout,它可以从布局的顶部/底部向下/向上移动。
从4.2开始,旧的SlidingDrawer就被废弃了,我还没有听说过一些实现相同功能的新Widget。
DrawerLayout是否可以以某种方式扩展以实现垂直滑动UX模式?谷歌是否提供了一些不同的小部件来实现它?
例如,谷歌音乐有一些非常类似于我想要实现的东西来拉出播放器。

发布于 2013-05-31 21:28:41
我们最近在Umano中实现了这一点,并且开源了:https://github.com/umano/AndroidSlidingUpPanel
好好享受吧。
发布于 2016-06-24 21:46:02
Android支持库现在已经具备了实现这一目的的底层操作。
查看此链接以获取更多信息https://material.google.com/components/bottom-sheets.html
发布于 2018-08-29 12:06:43
现在,使用BottomSheetBehavior更有意义,您可以找到关于如何在https://code.tutsplus.com/articles/how-to-use-bottom-sheets-with-the-design-support-library--cms-26031上设置它的更多信息。
基本上,您需要设置您的主要内容,和您的滑动内容。BottomSheetBehavior只适用于从底部到顶部滑动的面板。
它的设置非常简单,而且BottomSheetBehavior甚至可以开箱即用。只有通过编写带有另一个视图的android.support.design.widget.CoordinatorLayout布局(在layout_height参数中使用偶数wrap_content作为值),例如,如下所示的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>在我的例子中,我在Fragment中膨胀了这个布局,并将它添加到要启用SlidingSheetBehavior的Activity中。
https://stackoverflow.com/questions/16790129
复制相似问题