how to get bottomSheet to open from the top?

后端 未结 2 1580
长发绾君心
长发绾君心 2021-02-15 18:38

I\'m opening a NestedScrollView in my app and so far it opens from the bottom of the screen. How do I make it open from the top?

I tried removing the following line:

2条回答
  •  不思量自难忘°
    2021-02-15 19:19

    I'm not sure this is what you want, but the following link is a 'top' version of BottomSheetBehavior.

    https://github.com/ipuris/AndroidTopSheet/blob/master/library/src/main/java/com/github/techisfun/android/topsheet/TopSheetBehavior.java

    Full code including example app: https://github.com/ipuris/AndroidTopSheet

    Include the TopSheetBehavior class to your project, then you can use it by changing the app:layout_behavior value to TopSheetBehavior instead of android.support.design.widget.BottomSheetBehavior.

    Above code is forked from the original repository, but I fixed some library dependencies (old android.support library -> androidx library) for latest version of Android.

    (Maybe this answer is too late for @jernkuan, but I hope this answer can be helpful other developers.)

提交回复
热议问题