Giter Site home page Giter Site logo

slidingdrawer's Introduction

SlidingDrawer

A custom View implementing the bottom sheet pattern.
This ViewGroup can have only 2 children. The 1st one is the non slidable view ; the 2nd is the slidable view, which can slide over the non slidable view.

The substantial difference from all other implementations is that in this case is easy to position the collapsed slidable view relative to the non slidable view.
In other implementation the only way to control the position of the collapsed slidable view is by using a peek factor.
Here instead the collapsed slidable view is placed exactly below the non slidable view, just like in a vertical LinearLayout. The slidable view is conceptually part of the hierarchy and it's not above it.

Download the sample app here

Apps using this library: Shuffly


Download

Add this to you project-level build.gradle:

allprojects {
  repositories {
    ...
    maven { url "https://jitpack.io" }
  }
}

Add this to your module-level build.gradle:

dependencies {
  compile 'com.github.PierfrancescoSoffritti:SlidingDrawer:0.10'
}

Usage

<com.pierfrancescosoffritti.slidingdrawer.SlidingDrawer
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  
  android:id="@+id/sliding_drawer"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  app:shadow_length="4dp" >

  <View
    android:id="@id/non_slidable_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />
    
  <FrameLayout
    android:id="@id/slidable_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

</com.pierfrancescosoffritti.slidingdrawer.SlidingDrawer>

It's important to set the id attribute to android:id="@id/non_slidable_view" for the non slidable view and to android:id="@id/slidable_view" for the slidable view.

When you use this ViewGroup remember to always add a drag view slidingDrawer.setDragView(view);
The drag view is the only surface from which the slidable view can be dragged.

In case the slidable view has different views when collapsed (collapsed view) or expanded (expanded view), and the collapsed view isn't a List (or equivalent), it should have the id android:id="@id/sliding_drawer_collapsed_view", so the SlidingDrawer can adjust the view's paddingBottom to prevent it's content from going offscreen.

slidingdrawer's People

Contributors

pierfrancescosoffritti avatar

Watchers

Michael jentsch avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.