How to handle issues of the new bottom sheet of the support/design library?

前端 未结 2 355
野的像风
野的像风 2021-02-01 09:47

Background

I\'ve used a modified version of bottom-sheet library (here, based on this library, also wrote about it here), in order to have a nice transition between co

相关标签:
2条回答
  • 2021-02-01 10:25

    UPDATE Link to the full answer in where you can find all the explanation about how to get full behaviors like Google Maps.


    Helping you with what you want

    what I wanted, which is the 3-phases I've done before

    Using Support Library 23.x+ you can do it modifying default BottomSheetBehavior adding one more stat with following steps:

    1. Create a Java class and extend it from CoordinatorLayout.Behavior<V>
    2. Copy paste code from default BottomSheetBehavior file to your new one.
    3. Modify the method clampViewPositionVertical:

    4. Add a new state

      public static final int STATE_ANCHOR_POINT = X;

    5. Modify the next methods: onLayoutChild, onStopNestedScroll, BottomSheetBehavior<V> from(V view) and setState (optional)

    So now you have those states:
    STATE_HIDDEN
    STATE_COLLAPSED
    STATE_DRAGGING
    STATE_ANCHOR_POINT
    STATE_EXPANDED.

    You can use setBottomSheetCallback like you do in original BottomSheetBehavior

    The XML (without anything about parallax image like google maps) looks like:

    <CoordinatorLayout>
    
        <FrameLayout/>
    
        <AppBarLayout>
            <CollapsingToolbarLayout>
                <Toolbar/>
            </CollapsingToolbarLayout >
        </AppBarLayout >
    
        <NestedScrollView>
            <LinearLayout/>
        </NestedScrollView>
    
    </CoordinatorLayout >
    



    I'm going to add a link to the example project where you can find what you are looking for

    And here is how its looks like:
    [CustomBottomSheetBehavior]

    0 讨论(0)
  • 2021-02-01 10:31

    You can use this library. As far as I have seen there is no issue with this library.

    0 讨论(0)
提交回复
热议问题