All Projects → davidmigloz → drag-to-close

davidmigloz / drag-to-close

Licence: Apache-2.0 license
Android library that provides a view group which allows to finish an activity by dragging a view.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to drag-to-close

SlipperyLayout
A layout that supports sliding.
Stars: ✭ 44 (-36.23%)
Mutual labels:  view, viewgroup
ShadowDrawable
为View 和 ViewGroup 添加阴影效果--Android,Add shadow for single view or viewgroup layout.
Stars: ✭ 22 (-68.12%)
Mutual labels:  view, viewgroup
Discretescrollview
A scrollable list of items that centers the current element and provides easy-to-use APIs for cool item animations.
Stars: ✭ 5,533 (+7918.84%)
Mutual labels:  view, swipe
Nestedtouchscrollinglayout
🎱处理子 View,父 View 嵌套滚动,成本比 support v4 NestedScrolling 低,放心食用~
Stars: ✭ 557 (+707.25%)
Mutual labels:  view, viewgroup
Slidemenulayout
🔥An android slide menu that supports left and right swipes and slides with parallax.(一个支持左右滑动并带有视差滑动效果的安卓侧滑菜单控件.仿[QQ/探探侧滑])
Stars: ✭ 235 (+240.58%)
Mutual labels:  view, viewgroup
Chips Input Layout
A customizable Android ViewGroup for displaying Chips (specified in the Material Design Guide).
Stars: ✭ 591 (+756.52%)
Mutual labels:  view, viewgroup
Android Toy
不积跬步 无以至千里
Stars: ✭ 54 (-21.74%)
Mutual labels:  view, activity
bubble-layout
An Android ViewGroup that displays avatar bubbles... similar to the chat bubbles on Facebook Messenger.
Stars: ✭ 46 (-33.33%)
Mutual labels:  view, viewgroup
Youtubevideosample
YoutubeVideoSample
Stars: ✭ 176 (+155.07%)
Mutual labels:  view, drag
Expansionpanel
Android - Expansion panels contain creation flows and allow lightweight editing of an element.
Stars: ✭ 1,984 (+2775.36%)
Mutual labels:  view, close
Hauler
Library with swipe to dismiss Activity gesture implementation
Stars: ✭ 325 (+371.01%)
Mutual labels:  view, activity
bottomsheets
Material Bottom Sheets library for Android
Stars: ✭ 76 (+10.14%)
Mutual labels:  view, viewgroup
Slidingrootnav
DrawerLayout-like ViewGroup, where a "drawer" is hidden under the content view, which can be shifted to make the drawer visible.
Stars: ✭ 2,939 (+4159.42%)
Mutual labels:  view, swipe
vue2-data-tree
A tree that data is lazy loaded. Support dragging node, checking node, editing node's name and selecting node.
Stars: ✭ 41 (-40.58%)
Mutual labels:  drag, draggable
YoutubeVideoSample
YoutubeVideoSample
Stars: ✭ 176 (+155.07%)
Mutual labels:  view, drag
Viewtooltip
A fluent tooltip for Android
Stars: ✭ 1,029 (+1391.3%)
Mutual labels:  view, activity
CoolView
一些炫酷的自定义控件(Some cool custom controls),逐步完善中...
Stars: ✭ 63 (-8.7%)
Mutual labels:  view, viewgroup
FlowlayoutTags
具有标签功能的流式布局,接口简单。可多选单选,可记住选择状态,状态切换有过渡动画。
Stars: ✭ 78 (+13.04%)
Mutual labels:  view, viewgroup
Calendarview
Calendar View Library
Stars: ✭ 71 (+2.9%)
Mutual labels:  view, viewgroup
react-native-dnd-board
A drag and drop Kanban board for React Native.
Stars: ✭ 41 (-40.58%)
Mutual labels:  drag, draggable

Drag to close

Android library that provides a view group which allows to finish an activity by dragging a view.

image

Usage

Step 1

Add the JitPack repository to your build.gradle file:

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

Step 2

Add the dependency:

dependencies {
	implementation 'com.github.davidmigloz:drag-to-close:1.0.0'
}

CHANGELOG

Step 3

Use DragToClose view group to your layout:

<com.davidmiguel.dragtoclose.DragToClose
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:drag="http://schemas.android.com/apk/res-auto"
    ...
    drag:dragtoclose_draggableContainer="@+id/card"
    drag:dragtoclose_draggableView="@+id/close_arrow"
    drag:dragtoclose_finishActivity="false"
    drag:dragtoclose_closeOnClick="true">

    ...
</com.davidmiguel.dragtoclose.DragToClose>  

Attributes

  • drag:dragtoclose_draggableContainer="[reference]" (required): view that is going to be dragged (in the example, the card).
  • drag:dragtoclose_draggableView="[reference]" (required): view that is going to listen to draggable events (in the example, the arrow).
  • drag:dragtoclose_finishActivity="[true|false]" (default: true): when the draggableContainer is dragged out of the DragToClose view, the activity is finished (activity.finish() is called).
  • drag:dragtoclose_closeOnClick="[true|false]" (default: false): when the draggableView is clicked, draggableContainer is slid down out of the DragToClose view automatically (activity.finish() is called if need be).

Methods

  • getDraggableViewId(): returns the draggable view id.
  • setDraggableViewId(@IdRes int draggableViewId): sets the draggable view id.
  • getDraggableContainerId(): returns the draggable container id.
  • setDraggableContainerId(@IdRes int draggableContainerId): sets the draggable container id.
  • isFinishActivity(): checks whether finish activity is activated or not.
  • setFinishActivity(boolean finishActivity): sets finish activity attribute. If true, the activity is closed when the view is dragged out. Default: true.
  • isCloseOnClick(): checks whether close on click is activated or not.
  • setCloseOnClick(boolean closeOnClick): sets close on click attribute. If true, the draggable container is slid down when the draggable view is clicked. Default: false.
  • setDragListener(DragListener listener): sets drag listener.
  • closeDraggableContainer(): slides down draggable container out of the DragToClose view (activity.finish() is called if need be).
  • openDraggableContainer(): slides up draggable container to its original position.

Callback

If you want to listen to dragging events, you can use DragListener:

  • onStartDraggingView(): invoked when the view has just started to be dragged.
  • onDragging(dragOffset): invoked when the view is being dragged.
  • onViewCosed(): invoked when the view has being dragged out of the screen and just before calling activity.finish() (if need be).
dragToClose.setDragListener(object : DragListener {
    override fun onStartDraggingView() {...}
    override fun onDragging(dragOffset: Float) {...}
    override fun onViewCosed() {...}
})

Take a look at the sample app to see the library working.

Thanks to

  • DragQueen: sample app that shows android's ViewDragHelper usage.
  • DraggablePanel: Android library used to create an awesome Android UI based on a draggable element similar to the last YouTube graphic component.
  • SwipeBack: Android library that can finish a activity by using gesture.

Contributing

If you find any issues or you have any questions, ideas... feel free to open an issue. Pull request are very appreciated.

License

Copyright (c) 2018 David Miguel Lozano

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License 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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].