Making panel at the top disappear after sliding up in Umano SlidingUpPanel

时间:2019-01-07 13:15:40

标签: android android-studio

I am using Umano SlidingUpPanel library(https://github.com/umano/AndroidSlidingUpPanel) for my app and it fits pretty well. However, after sliding the panel up, it moves to the top of the page(by default). Is there any way of making the panel at the top completely disappear after sliding it up from the bottom of the first view?

1 个答案:

答案 0 :(得分:1)

根据AndroidSlidingUpPanel的文档,最简单的解决方案是侦听PanelState的更改,并在扩展它时设置您不希望对GONE看到的面板的可见性,反之亦然。

代码如下:

slidingPanelLayout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout);
slidingPanelLayout.addPanelSlideListener(new PanelSlideListener() {
        @Override
        public void onPanelSlide(View panel, float slideOffset) {

        }

        @Override
        public void onPanelStateChanged(View panel, PanelState previousState, PanelState newState) {
            if (newState == PanelState.EXPANDED) {
                //here you can set the visibility of the panel you want to hide to GONE
            } else {
                //and here you would set the panel to VISIBLE again
            }
        }
    });

我还有另外一个提示,那就是使用BottomSheetDialogFragment,它是针对这种用例的本地android解决方案。

https://developer.android.com/reference/android/support/design/widget/BottomSheetDialogFragment

https://medium.com/@kosta.palash/using-bottomsheetdialogfragment-with-material-design-guideline-f9814c39b9fc