Convert Figma logo to code with AI

umano logoAndroidSlidingUpPanel

This library provides a simple way to add a draggable sliding up panel (popularized by Google Music and Google Maps) to your Android application. Brought to you by Umano.

9,494
2,266
9,494
299

Top Related Projects

SlideUp is a small library that allows you to add sweet slide effect to any view.

Material Design Search Bar for Android

Side menu with some categories to choose.

A vertical-handled and multi-panel support SlidingPanelLayout. 一个竖直方向的SlidingPanelLayout,支持加载多个Panel,可以灵活地实现漂亮的的交互效果。

swipe display drawer with flowing & bouncing effects.

Quick Overview

AndroidSlidingUpPanel is an Android library that provides a draggable sliding up panel widget. It allows developers to easily add a secondary, hideable view that slides up from the bottom of the screen, similar to the UI pattern used in apps like Google Maps and Spotify.

Pros

  • Easy to implement and customize
  • Smooth animation and gesture handling
  • Supports both programmatic and XML-based configuration
  • Compatible with a wide range of Android versions

Cons

  • Limited to vertical sliding only
  • May conflict with other touch-based gestures in complex layouts
  • Requires careful consideration of layout hierarchy to avoid z-index issues
  • Not actively maintained (last update was in 2018)

Code Examples

  1. Basic implementation in XML:
<com.sothree.slidinguppanel.SlidingUpPanelLayout
    android:id="@+id/sliding_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="bottom">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/main_content">
        <!-- Main content goes here -->
    </FrameLayout>

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/sliding_content">
        <!-- Sliding panel content goes here -->
    </FrameLayout>

</com.sothree.slidinguppanel.SlidingUpPanelLayout>
  1. Programmatically controlling the panel:
val slidingLayout: SlidingUpPanelLayout = findViewById(R.id.sliding_layout)

// Open the panel
slidingLayout.panelState = SlidingUpPanelLayout.PanelState.EXPANDED

// Close the panel
slidingLayout.panelState = SlidingUpPanelLayout.PanelState.COLLAPSED
  1. Adding a panel state change listener:
slidingLayout.addPanelSlideListener(object : SlidingUpPanelLayout.PanelSlideListener {
    override fun onPanelSlide(panel: View, slideOffset: Float) {
        // Handle panel slide
    }

    override fun onPanelStateChanged(panel: View, previousState: SlidingUpPanelLayout.PanelState, newState: SlidingUpPanelLayout.PanelState) {
        // Handle panel state change
    }
})

Getting Started

  1. Add the dependency to your build.gradle file:
dependencies {
    implementation 'com.sothree.slidinguppanel:library:3.4.0'
}
  1. Add the SlidingUpPanelLayout to your layout XML file as shown in the first code example above.

  2. In your activity or fragment, initialize the SlidingUpPanelLayout:

val slidingLayout: SlidingUpPanelLayout = findViewById(R.id.sliding_layout)
// Customize the panel behavior as needed
slidingLayout.anchorPoint = 0.5f
slidingLayout.shadowHeight = 10
  1. Add your content to the main view and sliding panel view, and you're ready to go!

Competitor Comparisons

SlideUp is a small library that allows you to add sweet slide effect to any view.

Pros of SlideUp-Android

  • More lightweight and focused on a single sliding functionality
  • Easier to implement and customize for simple sliding panel needs
  • Actively maintained with recent updates and contributions

Cons of SlideUp-Android

  • Less feature-rich compared to AndroidSlidingUpPanel
  • Limited to vertical sliding only, while AndroidSlidingUpPanel supports both vertical and horizontal sliding
  • Smaller community and fewer resources available for troubleshooting

Code Comparison

SlideUp-Android implementation:

SlideUp(slideView)
    .withStartGravity(Gravity.BOTTOM)
    .withLoggingEnabled(true)
    .withStartState(SlideUp.State.HIDDEN)
    .withSlideFromOtherView(otherView)
    .build()

AndroidSlidingUpPanel implementation:

SlidingUpPanelLayout layout = findViewById(R.id.sliding_layout);
layout.addPanelSlideListener(new PanelSlideListener() {
    @Override
    public void onPanelSlide(View panel, float slideOffset) {}
    @Override
    public void onPanelStateChanged(View panel, PanelState previousState, PanelState newState) {}
});

Both libraries offer simple implementation, but AndroidSlidingUpPanel provides more built-in customization options and event listeners. SlideUp-Android focuses on a more streamlined approach for basic sliding functionality.

Material Design Search Bar for Android

Pros of MaterialSearchBar

  • Focused on search functionality with built-in suggestions and customizable UI
  • Lightweight and easy to integrate into existing Android projects
  • Supports voice search and custom animations

Cons of MaterialSearchBar

  • Limited to search bar functionality, less versatile than AndroidSlidingUpPanel
  • May require additional customization for complex search implementations
  • Less actively maintained, with fewer recent updates

Code Comparison

MaterialSearchBar:

MaterialSearchBar searchBar = findViewById(R.id.searchBar);
searchBar.setHint("Search");
searchBar.setOnSearchActionListener(new MaterialSearchBar.OnSearchActionListener() {
    @Override
    public void onSearchStateChanged(boolean enabled) {
        // Handle search state change
    }
});

AndroidSlidingUpPanel:

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

While MaterialSearchBar provides a specialized search component with built-in features, AndroidSlidingUpPanel offers a more versatile sliding panel that can be used for various purposes, including search functionality. The code comparison shows that MaterialSearchBar focuses on search-specific methods, while AndroidSlidingUpPanel provides general panel manipulation methods.

Side menu with some categories to choose.

Pros of Side-Menu.Android

  • Offers a visually appealing and customizable side menu animation
  • Provides a modern and sleek design that enhances user experience
  • Includes sample code and a demo app for easy implementation

Cons of Side-Menu.Android

  • Limited to side menu functionality, less versatile than AndroidSlidingUpPanel
  • May require more customization for specific use cases
  • Less actively maintained, with fewer recent updates

Code Comparison

Side-Menu.Android:

val menuFragment = MenuFragment()
val contentFragment = ContentFragment()

supportFragmentManager.beginTransaction()
    .replace(R.id.content_frame, contentFragment)
    .replace(R.id.menu_frame, menuFragment)
    .commit()

AndroidSlidingUpPanel:

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

Both libraries offer unique features for enhancing Android UI. Side-Menu.Android focuses on creating an attractive side menu with smooth animations, while AndroidSlidingUpPanel provides a versatile sliding panel that can be used for various purposes. The choice between the two depends on the specific requirements of your project and the desired user interface design.

A vertical-handled and multi-panel support SlidingPanelLayout. 一个竖直方向的SlidingPanelLayout,支持加载多个Panel,可以灵活地实现漂亮的的交互效果。

Pros of SlidingUpPanelLayout

  • More recent updates and active maintenance
  • Additional customization options, including shadow and overlay features
  • Better support for modern Android development practices and libraries

Cons of SlidingUpPanelLayout

  • Smaller community and fewer contributors compared to AndroidSlidingUpPanel
  • Less extensive documentation and fewer examples available
  • May have compatibility issues with older Android versions

Code Comparison

AndroidSlidingUpPanel:

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

SlidingUpPanelLayout:

mLayout = findViewById(R.id.sliding_layout);
mLayout.setPanelState(PanelState.COLLAPSED);
mLayout.addPanelSlideListener(new PanelSlideListener() {
    @Override
    public void onPanelSlide(View panel, float slideOffset) {}
});

The code usage is quite similar between the two libraries, with minor differences in import statements and class names. Both provide similar core functionality for implementing a sliding up panel in Android applications.

swipe display drawer with flowing & bouncing effects.

Pros of FlowingDrawer

  • Offers a unique, fluid animation effect for the drawer
  • Provides customizable menu items with icons
  • Supports both left and right-side drawer placement

Cons of FlowingDrawer

  • Less actively maintained (last update in 2017)
  • Limited documentation and examples
  • May require more setup and customization for basic functionality

Code Comparison

AndroidSlidingUpPanel:

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

FlowingDrawer:

mDrawer = (FlowingDrawer) findViewById(R.id.drawerlayout);
mDrawer.setTouchMode(ElasticDrawer.TOUCH_MODE_BEZEL);
mDrawer.setOnDrawerStateChangeListener(new ElasticDrawer.OnDrawerStateChangeListener() {
    @Override
    public void onDrawerStateChange(int oldState, int newState) {
        // Handle drawer state change
    }
});

Both libraries offer unique sliding panel implementations, but AndroidSlidingUpPanel focuses on a bottom-up sliding panel, while FlowingDrawer provides a side drawer with fluid animations. AndroidSlidingUpPanel is more actively maintained and has better documentation, making it easier to implement for basic use cases. FlowingDrawer offers a visually appealing animation effect but may require more effort to set up and customize.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Maven Central Badge

Note: we are not actively responding to issues right now. If you find a bug, please submit a PR.

Android Sliding Up Panel

This library provides a simple way to add a draggable sliding up panel (popularized by Google Music and Google Maps) to your Android application.

As seen in Umano Android App (now acquired by Dropbox):

SlidingUpPanelLayout

Known Uses in Popular Apps

If you are using the library and you would like to have your app listed, simply let us know.

Importing the Library

Simply add the following dependency to your build.gradle file to use the latest version:

dependencies {
    repositories {
        mavenCentral()
    }
    compile 'com.sothree.slidinguppanel:library:3.4.0'
}

Usage

  • Include com.sothree.slidinguppanel.SlidingUpPanelLayout as the root element in your activity layout.
  • The layout must have gravity set to either top or bottom.
  • Make sure that it has two children. The first child is your main layout. The second child is your layout for the sliding up panel.
  • The main layout should have the width and the height set to match_parent.
  • The sliding layout should have the width set to match_parent and the height set to either match_parent, wrap_content or the max desireable height. If you would like to define the height as the percetange of the screen, set it to match_parent and also define a layout_weight attribute for the sliding view.
  • By default, the whole panel will act as a drag region and will intercept clicks and drag events. You can restrict the drag area to a specific view by using the setDragView method or umanoDragView attribute.

For more information, please refer to the sample code.

<com.sothree.slidinguppanel.SlidingUpPanelLayout
    xmlns:sothree="http://schemas.android.com/apk/res-auto"
    android:id="@+id/sliding_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="bottom"
    sothree:umanoPanelHeight="68dp"
    sothree:umanoShadowHeight="4dp">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:text="Main Content"
        android:textSize="16sp" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center|top"
        android:text="The Awesome Sliding Up Panel"
        android:textSize="16sp" />
</com.sothree.slidinguppanel.SlidingUpPanelLayout>

For smooth interaction with the ActionBar, make sure that windowActionBarOverlay is set to true in your styles:

<style name="AppTheme">
    <item name="android:windowActionBarOverlay">true</item>
</style>

However, in this case you would likely want to add a top margin to your main layout of ?android:attr/actionBarSize or ?attr/actionBarSize to support older API versions.

Caveats, Additional Features and Customization

  • If you are using a custom umanoDragView, the panel will pass through the click events to the main layout. Make your second layout clickable to prevent this.
  • You can change the panel height by using the setPanelHeight method or umanoPanelHeight attribute.
  • If you would like to hide the shadow above the sliding panel, set shadowHeight attribute to 0.
  • Use setEnabled(false) to completely disable the sliding panel (including touch and programmatic sliding)
  • Use setTouchEnabled(false) to disables panel's touch responsiveness (drag and click), you can still control the panel programatically
  • Use getPanelState to get the current panel state
  • Use setPanelState to set the current panel state
  • You can add parallax to the main view by setting umanoParallaxOffset attribute (see demo for the example).
  • You can set a anchor point in the middle of the screen using setAnchorPoint to allow an intermediate expanded state for the panel (similar to Google Maps).
  • You can set a PanelSlideListener to monitor events about sliding panes.
  • You can also make the panel slide from the top by changing the layout_gravity attribute of the layout to top.
  • You can provide a scroll interpolator for the panel movement by setting umanoScrollInterpolator attribute. For instance, if you want a bounce or overshoot effect for the panel.
  • By default, the panel pushes up the main content. You can make it overlay the main content by using setOverlayed method or umanoOverlay attribute. This is useful if you would like to make the sliding layout semi-transparent. You can also set umanoClipPanel to false to make the panel transparent in non-overlay mode.
  • By default, the main content is dimmed as the panel slides up. You can change the dim color by changing umanoFadeColor. Set it to "@android:color/transparent" to remove dimming completely.

Scrollable Sliding Views

If you have a scrollable view inside of the sliding panel, make sure to set umanoScrollableView attribute on the panel to supported nested scrolling. The panel supports ListView, ScrollView and RecyclerView out of the box, but you can add support for any type of a scrollable view by setting a custom ScrollableViewHelper. Here is an example for NestedScrollView

public class NestedScrollableViewHelper extends ScrollableViewHelper {
  public int getScrollableViewScrollPosition(View scrollableView, boolean isSlidingUp) {
    if (mScrollableView instanceof NestedScrollView) {
      if(isSlidingUp){
        return mScrollableView.getScrollY();
      } else {
        NestedScrollView nsv = ((NestedScrollView) mScrollableView);
        View child = nsv.getChildAt(0);
        return (child.getBottom() - (nsv.getHeight() + nsv.getScrollY()));
      }
    } else {
      return 0;
    }
  }
}

Once you define your helper, you can set it using setScrollableViewHelper on the sliding panel.

Implementation

This library was initially based on the opened-sourced SlidingPaneLayout component from the r13 of the Android Support Library. Thanks Android team!

Requirements

Tested on Android 2.2+

Other Contributors

  • Nov 23, 15 - @kiyeonk - umanoScrollInterpolator support
  • Jan 21, 14 - ChaYoung You (@yous) - Slide from the top support
  • Aug 20, 13 - @gipi - Android Studio Support
  • Jul 24, 13 - Philip Schiffer (@hameno) - Maven Support
  • Oct 20, 13 - Irina Preșa (@iriina) - Anchor Support
  • Dec 1, 13 - (@youchy) - XML Attributes Support
  • Dec 22, 13 - Vladimir Mironov (@MironovNsk) - Custom Expanded Panel Height

If you have an awesome pull request, send it over!

Changelog

  • 3.4.0
    • Use the latest support library 26 and update the min version to 14.
    • Bug fixes
  • 3.3.1
    • Lots of bug fixes from various pull requests.
    • Removed the nineoldandroids dependency. Use ViewCompat instead.
  • 3.3.0
    • You can now set a FadeOnClickListener, for when the faded area of the main content is clicked.
    • PanelSlideListener has a new format (multiple of them can be set now
    • Fixed the setTouchEnabled bug
  • 3.2.1
    • Add support for umanoScrollInterpolator
    • Add support for percentage-based sliding panel height using layout_weight attribute
    • Add ScrollableViewHelper to allow users extend support for new types of scrollable views.
  • 3.2.0
    • Rename umanoParalaxOffset to umanoParallaxOffset
    • RecyclerView support.
  • 3.1.0
    • Added umanoScrollableView to supported nested scrolling in children (only ScrollView and ListView are supported for now)
  • 3.0.0
    • Added umano prefix for all attributes
    • Added clipPanel attribute for supporting transparent panels in non-overlay mode.
    • setEnabled(false) - now completely disables the sliding panel (touch and programmatic sliding)
    • setTouchEnabled(false) - disables panel's touch responsiveness (drag and click), you can still control the panel programatically
    • getPanelState - is now the only method to get the current panel state
    • setPanelState - is now the only method to modify the panel state from code
  • 2.0.2 - Allow wrap_content for sliding view height attribute. Bug fixes.
  • 2.0.1 - Bug fixes.
  • 2.0.0 - Cleaned up various public method calls. Added animated showPanel/hidePanel methods.
  • 1.0.1 - Initial Release

Licence

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.