NewDI_Summer NewDI_Summer - 1 year ago 296
Android Question

About com.sothree.slidinguppanel.SlidingUpPanelLayout

When I used

, I have to set two children layout (main and panel). When the second layout (the panel) is opened, I want to close it using a
. But I couldn't find the method.

What is the method?

Answer Source


If I understand you well, you want to implement a listener when the second view is opened right?

The way to do that would be like this:

first declare an SlidingUpPanelLayout:

SlidingUpPanelLayout layout;

then, initialize it in onCreate()

layout = (SlidingUpPanelLayout) findViewById(;

After, that if you want, you can set its children clickable by:


Now, the important part is this one. Adding the listener to the layout

 layout.setPanelSlideListener(new PanelSlideListener() {

        public void onPanelSlide(View panel, float slideOffset) {
            // TODO Auto-generated method stub


        public void onPanelCollapsed(View panel) {
            // TODO Auto-generated method stub
            //Anything you put here is going to happen if the view is closed

        public void onPanelExpanded(View panel) {
            // TODO Auto-generated method stub
            //Anything you put here is going to happen if the view is open

        public void onPanelAnchored(View panel) {
            // TODO Auto-generated method stub


I hope this helps! Happy coding!

EDIT: If you want to close and/or open the pane, there are two boolean methods within the class:

layout.collapsePane(true); //to close
layout.expandPane(true); //to open

EDIT. Current Version Link to example

layout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED); //to close
layout.setPanelState(SlidingUpPanelLayout.PanelState.EXPANDED); //to open
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download