SwipeableLayout

Additional

Language
Java
Version
N/A
Created
Oct 30, 2015
Updated
Dec 14, 2015 (Retired)
Owner
Zabelnikov Sergey (ReginFell)
Contributors
Zabelnikov Sergey (ReginFell)
JenshenSoft
2
Activity
Badge
Generate
Download
Source code

Announcement

SwipeableLayout

Library to use swipe to close on your Layout.

Demo

Simple Transparent Activity (Video)

Transparent Activity with PagerView (Video)

Requirements

SwipeableLayout supports Android 4.0.0 (Ice Cream Sandwich) and later.

Gradle Dependency (jCenter)

If you are building with Gradle, simply add the following line to the dependencies section of your build.gradle file:

compile 'ua.zabelnikiov:swipeLayout:1.0'

Getting started

It's very easy, just add SwipeableLayout to your xml

    <ua.zabelnikov.swipelayout.layout.frame.SwipeableLayout
        android:id="@+id/swipeableLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

You can add some view to your SwipeableLayout

    <ua.zabelnikov.swipelayout.layout.frame.SwipeableLayout
        android:id="@+id/swipeableLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ImageView
            android:id="@+id/imageView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="centerCrop" />

    </ua.zabelnikov.swipelayout.layout.frame.SwipeableLayout>

If you need listener, in your code add:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        SwipeableLayout swipeableLayout = (SwipeableLayout) findViewById(R.id.swipeableLayout);

        swipeableLayout.setOnLayoutPercentageChangeListener(new OnLayoutPercentageChangeListener() {
            //OnLayoutPercentageChange return value from 0 to 1,
            //where 0 - view not swiped, 1 - view swiped to action
    
            @Override
            public void percentageY(float percentage) {
             
            }

            @Override
            public void percentageX(float percentage) {
                
            }
        });
        swipeableLayout.setOnSwipedListener(new OnLayoutSwipedListener() {
            @Override
            public void onLayoutSwiped() {
                //Do some action, when view was swiped. For example, you can close activity
            }
        });
    }

Also you can set Shifte listener:

   swipeableLayout.setLayoutShiftListener(new LayoutShiftListener() {
            @Override
            public void onLayoutShifted(float positionX, float positionY, boolean isTouched) {
             //DO SOME YOUR LOGIC
            }
        });

List of supported attributes:

     <ua.zabelnikov.swipelayout.layout.frame.SwipeableLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:swipeSpeed="3" 
        app:swipeOrientation="leftToRight"
        app:scrollAndClickable="false"/>

Changelog

Changelog

License:

The MIT License (MIT)

Copyright (c) 2015 

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.