SlidingDrawer

SlidingDrawer是一款实现底部抽屉模式的Android自定义视图组件。该组件支持两个子视图,即固定视图和滑动视图。滑动视图能够精确地放置在固定视图下方,并且可以通过拖拽视图进行操作。与传统的底部抽屉实现不同,该组件允许开发者更灵活地控制滑动视图的位置。

SlidingDrawer

简介:Android custom View implementing the bottom sheet pattern.

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 slidable viewrelative to the non slidable view.
In other implementations the only way to control the position of the slidable view, when collapsed, is by using a peek factor.
Here instead the 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 toandroid: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 idandroid:id="@id/sliding_drawer_collapsed_view", so the SlidingDrawer can adjust the view's paddingBottom to prevent its content from going offscreen.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值