Search code examples
androidslidingdrawerslideupandroid-sliding

How to change buttons when UpSlidePanel comes up in android


I am trying to make an app. I have implements the following sliding up panel https://github.com/umano/AndroidSlidingUpPanel

I am not able to figure out that how should I change the buttons when the panel is slided up.

For example, look the images attached

When the sliding panel is in the bottom, the pause, next and previous buttons are shown.

enter image description here

When I drag the panel up , the buttons are changed to some kind of toolbar with the "Now playing" text and other buttons

enter image description here

How can I implement this in my app?

Thanks in advance!


Solution

  • There is a listener and callback methods with this library and you can manipulate the panel using an anonymous inner class that implements the interface methods, basic example :

            SlidingUpPaneLayout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout);
            mSlidingUpPaneLayout.setPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {
    
                @Override
                public void onPanelSlide(View panel, float slideOffset) {
    
                }
    
                @Override
                public void onPanelCollapsed(View panel) {
                }
    
                @Override
                public void onPanelExpanded(View panel) {
    
                    panel.findViewById(R.id.myPanel)
                            .setBackgroundColor("whatever_resource_color");
                }
    
                @Override
                public void onPanelAnchored(View panel) {
                }
    
                @Override
                public void onPanelHidden(View panel) {
                }
            });
    

    In your case you could use a FrameLayout with 2 views, toggling the visibility to each view when the panel is closed or expanded, or something similar.