简体   繁体   中英

How to lock bottom sheet to his peek height?

I am using this library:

compile 'com.android.support:design:23.2.0'

And i did this bottom sheet but after some actions i want to lock it on the bottom of the screen only with 1 raw visible. This is the tutorial where I am looking from. I want to lock the bottom sheet like the 3rd item from the tutorial.

If you have any ideas will be great :)

Here is my code:

private void initBottomSheet() {
        mBottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
        mBottomSheetBehavior.setPeekHeight(200);
        mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
        mBottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
            @Override
            public void onStateChanged(View bottomSheet, int newState) {
                if (newState == BottomSheetBehavior.STATE_COLLAPSED) {
                    mBottomSheetBehavior.setPeekHeight(200);
                }
            }

            @Override
            public void onSlide(View bottomSheet, float slideOffset) {
            }
        });
    }

我认为您忘记使用此代码: mBottomSheetBehavior.setPeekHeight(300);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM