All Projects → zerobranch → Swipelayout

zerobranch / Swipelayout

Licence: mit
A library what allows you to execute a swipe for the android platform

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Swipelayout

Easygrid
EasyGrid - VanillaJS Responsive Grid
Stars: ✭ 77 (-48.67%)
Mutual labels:  library, layout
Vusikview
Android library to make notes drop animation for music players
Stars: ✭ 115 (-23.33%)
Mutual labels:  library, custom-view
React Swipeable List
Swipeable list component for React.
Stars: ✭ 86 (-42.67%)
Mutual labels:  list, swipe
Testleavesloading
Android 自定义 View 之 LeavesLoading
Stars: ✭ 55 (-63.33%)
Mutual labels:  custom-view, android-ui
Streaming
r/freemediaheckyeah
Stars: ✭ 147 (-2%)
Mutual labels:  library, list
Battery Meter View
🔋 Material design battery meter (i.e. level, state) view for Android
Stars: ✭ 57 (-62%)
Mutual labels:  custom-view, android-ui
Bubble Navigation
🎉 [Android Library] A light-weight library to easily make beautiful Navigation Bar with ton of 🎨 customization option.
Stars: ✭ 1,537 (+924.67%)
Mutual labels:  library, android-ui
Fillingbutton
🔥Replace typical onLongClickListener with this library!
Stars: ✭ 31 (-79.33%)
Mutual labels:  library, android-ui
Typed
The TypeScript Standard Library
Stars: ✭ 124 (-17.33%)
Mutual labels:  library, list
Androidrate
AndroidRate is a library to help you promote your Android app by prompting users to rate the app after using it for a few days.
Stars: ✭ 117 (-22%)
Mutual labels:  library, android-ui
Tagsedittext
Android TagsEditText View
Stars: ✭ 47 (-68.67%)
Mutual labels:  library, android-ui
Uistatus
一个简单且强大的Ui状态视图控制库!
Stars: ✭ 137 (-8.67%)
Mutual labels:  layout, android-ui
Duo Navigation Drawer
A flexible, easy to use, unique drawer library for your Android project.
Stars: ✭ 986 (+557.33%)
Mutual labels:  library, layout
Bubbles
⚡️A library for adding messenger style floating bubbles to any android application 📲
Stars: ✭ 66 (-56%)
Mutual labels:  library, android-ui
Bluetooth State View
Material design animated Bluetooth state view for Android
Stars: ✭ 36 (-76%)
Mutual labels:  custom-view, android-ui
Consecutivescroller
ConsecutiveScrollerLayout是Android下支持多个滑动布局(RecyclerView、WebView、ScrollView等)和普通控件(TextView、ImageView、LinearLayou、自定义View等)持续连贯滑动的容器,它使所有的子View像一个整体一样连续顺畅滑动。并且支持布局吸顶功能。
Stars: ✭ 1,383 (+822%)
Mutual labels:  custom-view, android-ui
Peppy Calendarview
Simple and fast Material Design calendar view for Android.
Stars: ✭ 30 (-80%)
Mutual labels:  custom-view, android-ui
Cardviewlist
An elegant and responsive CardView like Android on iOS with Swift. Available horizontal and vertical scrolling with full animations and customizable.
Stars: ✭ 30 (-80%)
Mutual labels:  library, android-ui
Truffle Shuffle
An Android data-driven, percentage-based UI Card Gallery Library
Stars: ✭ 117 (-22%)
Mutual labels:  library, android-ui
Googlenewsstandanimation Android
Navigation pattern like in Google News Stand app with transitions
Stars: ✭ 130 (-13.33%)
Mutual labels:  library, swipe

SwipeLayout

license Android Arsenal

SwipeLayout is a project for the android platform, providing the opportunity to perform swipe for any layout, in the specified direction.

Choose language

English

Русский

Description

SwipeLayout is just a 'Custom ViewGroup', extended from FrameLayout, which provides easy and fast to use the 'swipe to dismiss' function, without using the ItemTouchHelper, for any layout.

Download

Download the sample APK and try it out!

Screenshots

left.gif right.gif horizontal.gif

Features

  • Executing the swipe to the left
  • Executing the swipe to the right
  • Executing the swipe and left and right
  • Using any your layouts
  • Four modes of swipe, which can be combined with each other

Integration

Option 1 Copy the attrs.xml file to the src/res/values folder and the SwipeLayout.java file to the source code folder of your project from the gist and to use.

Option 2

Add it in your root build.gradle at the end of repositories:

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

Add the following dependency to your module's build.gradle:

dependencies {
    implementation 'com.github.zerobranch:SwipeLayout:1.3.1'
}

How to use ?

Example of use. Swipe to the left

<com.zerobranch.layout.SwipeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/swipe_layout"
    android:layout_width="match_parent"
    android:layout_height="90dp"
    app:draggedItem="@id/drag_item"
    app:rightItem="@id/right_view"
    app:swipeDirection="left">

    <ImageView
        android:id="@+id/right_view"
        android:layout_width="90dp"
        android:layout_height="match_parent"
        android:layout_gravity="end"
        android:background="#ff5722"
        android:gravity="center"
        android:paddingEnd="24dp"
        android:paddingStart="24dp"
        android:src="@drawable/ic_delete"/>
  
    <TextView  
        android:id="@+id/drag_item"  
        android:layout_width="match_parent"  
        android:layout_height="match_parent"  
        android:background="#eeeeee"  
        android:gravity="center_vertical"  
        android:paddingEnd="10dp"  
        android:paddingStart="20dp"  
        android:textSize="20sp"/>

</com.zerobranch.layout.SwipeLayout>
Above is an example of a layout. For the correct operation of the swipe it is necessary to add <mobile.sarproj.com.swipelayout.SwipeLayout in your layout in which you need to specify the following parameters:
- app:draggedItem="@id/drag_item", where drag_item is the id of the element to be dragged
- app:rightItem="@id/right_view", where right_view is the id of the element that will remain on the right with the swipe to the left (if you use swipe to the right, you must specify app: leftItem).
- app:swipeDirection="left" - direction of a swipe
  - app:swipeDirection="left" - swipe to the left
  - app:swipeDirection="right" - swipe to the right
  - app:swipeDirection="left|right" - swipe left and right

Description of parameters

Required

- app:draggedItem="@id/drag_item" - where drag_item is the id of the element to be dragged
- app:rightItem="@id/right_view" - where right_view - id of the element that will remain on the right with the swipe to the left
- app:leftItem="@id/left_view" - where left_view - id of the element that will remain on the left with the swipe to the right
- app:swipeDirection="left" - direction of a swipe
  - app:swipeDirection="left" - swipe to the left
  - app:swipeDirection="right" - swipe to the right
  - app:swipeDirection="left|right" - swipe left and right

Optional

- app:isFreeDragAfterOpen="false|true" - allows the main view to move after its opening
- app:isFreeHorizontalDrag="false|true" - allows you to move the main view in the opposite direction to the swipe
- app:isContinuousSwipe="false|true" - allows you to execute the swipe to the end of the screen
- app:isTogether="false|true" - the secondary view will move along with the main view
- app:autoMovingSensitivity="1000" - sensitivity of automatic closing of the main view
- app:rightDragViewPadding="0dp" - the right bounding border of the swipe for the main view
- app:leftDragViewPadding="0dp" - the left bounding border of the swipe for the main view
- app:isEnabledSwipe="false|true" - allows you to disable the swipe

Control from the code

SwipeLayout.close() - cancel swipe, return the main view to its original state
SwipeLayout.openLeft() - execute swipe to the right
SwipeLayout.openRight() - execute swipe to the left
SwipeLayout.openRightCompletely() - execute swipe to the right to the end of the screen 
SwipeLayout.openLeftCompletely() - execute swipe to the left to the end of the screen 
SwipeLayout.close(false) - cancel swipe, return the main view to its original state without animation
SwipeLayout.openLeft(false) - execute swipe to the right without animation
SwipeLayout.openRight(false) - execute swipe to the left without animation
SwipeLayout.openRightCompletely(false) - execute swipe to the right to the end of the screen without animation
SwipeLayout.openLeftCompletely(false) - execute swipe to the left to the end of the screen without animation
SwipeLayout.isClosed() - is the main view in the default state
SwipeLayout.isMoving() - is the main view in the moving
SwipeLayout.setEnabledSwipe(false) - allows you to disable the swipe
SwipeLayout.enableTouchForViewGroup(ViewGroup) - enable touch for ViewGroup

Callback

SwipeLayout.setOnActionsListener(new SwipeLayout.SwipeActionsListener() {
    @Override
    public void onOpen(int direction, boolean isContinuous) {
        if (direction == SwipeLayout.RIGHT) {
            // was executed swipe to the right
        } else if (direction == SwipeLayout.LEFT) {
            // was executed swipe to the left
        }
    }

    @Override  
    public void onClose() {  
        // the main view has returned to the default state
    }
});

Note

- the isContinuousSwipe flag works in two modes, with a secondary view (app:leftItem, app:rightItem) and without it
- if you use both swipe left and right (app:swipeDirection="left|right"), the isContinuousSwipe flag will be ignored
- if a specific direction of the swipe is specified and the isContinuousSwipe flag is set, the isFreeDragAfterOpen flag is automatically set to true
- if you use swipe and left and right (app:swipeDirection="left|right"), the isFreeHorizontalDrag flag will work differently. It will set the mode at which the main view will continuously move in both directions

License

The MIT License (MIT)

Copyright (c) 2018 Arman Sargsyan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
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].