1

I have implemented a layout with the BottomSheetBehaviourand set have set the behavior_peekHeight as 300dp and behavior_hideable as true.

Code Sample

 <FrameLayout
    android:id="@+id/sheet_layout"
    android:layout_width="match_parent"
    android:layout_height="@dimen/map_view_height"
    android:background="@color/white"
    app:behavior_hideable="true"
    app:behavior_peekHeight="300dp"
    app:behavior_skipCollapsed="true"
    app:layout_behavior="@string/bottom_sheet_behavior">

    <include layout="@layout/sheet_content_layout"/>

</FrameLayout>

Here I'm able to hide the layout with dragging to the bottom. But once I have dragged the layout to the bottom, I couldn't drag it back to it's original peek height. How can I do that?

ImMathan
  • 3,911
  • 4
  • 29
  • 45
  • I don't think it is good to ask the user to drag it from the bottom, especially for those who are using software bottom. – BakaWaii Aug 12 '17 at 08:56
  • @BakaWaii I'll be showing a minimal section to be dragged to the top. For example, if you use the new Uber you will be able to drag the messages from the bottom. – ImMathan Aug 12 '17 at 09:06

1 Answers1

2

You can't have BottomSheet with multiple peekHeight. That means you can't set the height of BottomSheet in expanded state. At least, not without modifying the BottomSheetBehavior class to your specific use case. This may help in that regard: Sliding up image with Official Support Library 23.x.+ bottomSheet like google maps

However, if you just want a bottomSheetView that is at a height of say 100dp in collapsed state and that can be expanded to full screen and dragged back to 100dp, you can use the default behavior.

<FrameLayout
    android:id="@+id/sheet_layout"
    android:layout_width="match_parent"
    android:layout_height="@dimen/map_view_height"
    android:background="@color/white"
    app:behavior_peekHeight="100dp"
    app:layout_behavior="@string/bottom_sheet_behavior">

    <include layout="@layout/sheet_content_layout"/>

</FrameLayout>

You could also have a look at physics based animation introduced this year in IO. It has an easy to use FlingAnimation class, https://developer.android.com/topic/libraries/support-library/preview/fling-animation.html

div
  • 1,475
  • 3
  • 22
  • 32