An Android library that help you to build app with swipe back gesture.

Overview

SwipeBackLayout

An Android library that help you to build app with swipe back gesture.

Demo Apk

GooglePlay

Requirement

The latest android-support-v4.jar should be referenced by your project.

Usage

  1. Add SwipeBackLayout as a dependency to your existing project.
  2. To enable SwipeBackLayout, you can simply make your Activity extend SwipeBackActivity:
    • In onCreate method, setContentView() should be called as usual.
    • You will have access to the getSwipeBackLayout() method so you can customize the SwipeBackLayout.
  3. Make window translucent by adding <item name="android:windowIsTranslucent">true</item> to your theme.

Simple Example

public class DemoActivity extends SwipeBackActivity implements View.OnClickListener {
    private int[] mBgColors;

    private static int mBgIndex = 0;

    private String mKeyTrackingMode;

    private RadioGroup mTrackingModeGroup;

    private SwipeBackLayout mSwipeBackLayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_demo);
        changeActionBarColor();
        findViews();
        mKeyTrackingMode = getString(R.string.key_tracking_mode);
        mSwipeBackLayout = getSwipeBackLayout();

        mTrackingModeGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                int edgeFlag;
                switch (checkedId) {
                    case R.id.mode_left:
                        edgeFlag = SwipeBackLayout.EDGE_LEFT;
                        break;
                    case R.id.mode_right:
                        edgeFlag = SwipeBackLayout.EDGE_RIGHT;
                        break;
                    case R.id.mode_bottom:
                        edgeFlag = SwipeBackLayout.EDGE_BOTTOM;
                        break;
                    default:
                        edgeFlag = SwipeBackLayout.EDGE_ALL;
                }
                mSwipeBackLayout.setEdgeTrackingEnabled(edgeFlag);
                saveTrackingMode(edgeFlag);
            }
        });
    }
...

Download

Download via Jcenter:

compile 'me.imid.swipebacklayout.lib:library:1.1.0'

Support

Pull Requests

I will gladly accept pull requests for fixes and feature enhancements but please do them in the develop branch.

License

Copyright 2013 Isaac Wang

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.

Comments
  • android 4.4.4侧滑退出显示app启动界面

    android 4.4.4侧滑退出显示app启动界面

    RT: 情况,我手机上两台手机:nexus5(4.4.4)与化为X6(4.4.2)退出滑动效果不一致。 两台手机都是运行同一套代码 1,nexus5 只有当activity完全退出时,前一个activity才出弹出 2,华为X6则可以完美展示(即在滑动退出时,就可以看见前一个activity)

    (已经设置透明主题) 参考过这个问题: https://github.com/Issacw0ng/SwipeBackLayout/issues/4

    opened by lejun 16
  • 左滑返回时出现黑屏

    左滑返回时出现黑屏

    RT: 具体描述: (0)一个子Activity继承自SwipeBackActivity,没有作任何修改。 (1)在一个子Activity中从左边滑动想返回时,屏幕变黑。再按两次按物理返回键时 可以回到父Activity中(感觉进入了一个子Activity与父Activity的一个中间黑色界面) (2)系统MIUI V5 3.8.16

    opened by codetalks-new 16
  • 快速滑动关闭 出现空指针

    快速滑动关闭 出现空指针

    07-27 15:33:32.015: E/AndroidRuntime(9325): java.lang.NullPointerException 07-27 15:33:32.015: E/AndroidRuntime(9325): at android.view.View.getHardwareLayer(View.java:10215) 07-27 15:33:32.015: E/AndroidRuntime(9325): at android.view.ViewGroup.drawChild(ViewGroup.java:2947) 07-27 15:33:32.015: E/AndroidRuntime(9325): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2573) 07-27 15:33:32.015: E/AndroidRuntime(9325): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchDraw(PhoneWindow.java) 07-27 15:33:32.015: E/AndroidRuntime(9325): at android.view.View.getDisplayList(View.java:10452) 07-27 15:33:32.015: E/AndroidRuntime(9325): at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:856) 07-27 15:33:32.015: E/AndroidRuntime(9325): at android.view.ViewRootImpl.draw(ViewRootImpl.java:2089) 07-27 15:33:32.015: E/AndroidRuntime(9325): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1787) 07-27 15:33:32.015: E/AndroidRuntime(9325): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2642) 07-27 15:33:32.015: E/AndroidRuntime(9325): at android.os.Handler.dispatchMessage(Handler.java:99) 07-27 15:33:32.015: E/AndroidRuntime(9325): at android.os.Looper.loop(Looper.java:154) 07-27 15:33:32.015: E/AndroidRuntime(9325): at android.app.ActivityThread.main(ActivityThread.java:4624) 07-27 15:33:32.015: E/AndroidRuntime(9325): at java.lang.reflect.Method.invokeNative(Native Method) 07-27 15:33:32.015: E/AndroidRuntime(9325): at java.lang.reflect.Method.invoke(Method.java:511) 07-27 15:33:32.015: E/AndroidRuntime(9325): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809) 07-27 15:33:32.015: E/AndroidRuntime(9325): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576) 07-27 15:33:32.015: E/AndroidRuntime(9325): at dalvik.system.NativeStart.main(Native Method)

    opened by jingjing0327 10
  • edge_flag

    edge_flag

    Caused by: java.lang.NumberFormatException: For input string: "50.0dip" at java.lang.Integer.parseInt(Integer.java:521) at com.android.internal.util.XmlUtils.convertValueToInt(XmlUtils.java:133) at android.content.res.TypedArray.getInt(TypedArray.java:367) at me.imid.swipebacklayout.lib.SwipeBackLayout.(SwipeBackLayout.java:142) at me.imid.swipebacklayout.lib.SwipeBackLayout.(SwipeBackLayout.java:129)

    opened by aaaking 9
  • On android 4.4.4 when swiping I see my phone's background

    On android 4.4.4 when swiping I see my phone's background

    Tried the version in the play store, When I swipe instead of showing the old activity it shows my phone background / the task manager. this happens on 4.4.4

    opened by rootux 9
  • 在 android 4.4.2 下滑动返回时下方 Activity 会透明

    在 android 4.4.2 下滑动返回时下方 Activity 会透明

    直接透过显示出 Launcher 。

    而如果将下方的 Activity 的 windowIsTranslucent 设为false, 则覆盖在上面的 Activity 在滑动返回时表现正常,在调用 scrollToFinishActivity 时看不到下方的Activity(显示为黑色)

    在 https://github.com/Issacw0ng/SwipeBackLayout/commit/9560c70cd40b03996fbb1aefad2fb8ca98820fab 提交之前,scrollToFinishActivity 同样正常。

    请问该如何解决,谢谢~

    Nexus5 Android 4.4.2, targetSdkVersion 19

    opened by richard1122 9
  • java.lang.StackOverflowError

    java.lang.StackOverflowError

    java.lang.StackOverflowError at android.text.Styled.measureText(Styled.java:454) at android.text.Layout.measureText(Layout.java:1970) at android.text.Layout.getLineMax(Layout.java:912) at android.text.Layout.draw(Layout.java:414) at android.text.BoringLayout.draw(BoringLayout.java:365) at android.widget.TextView.onDraw(TextView.java:4431) at android.view.View.draw(View.java:6880) at android.view.ViewGroup.drawChild(ViewGroup.java:1646) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) at android.view.ViewGroup.drawChild(ViewGroup.java:1644) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) at android.view.ViewGroup.drawChild(ViewGroup.java:1644) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) at android.view.ViewGroup.drawChild(ViewGroup.java:1644) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) at android.view.ViewGroup.drawChild(ViewGroup.java:1644) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) at android.view.ViewGroup.drawChild(ViewGroup.java:1644) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) at android.view.View.draw(View.java:6883) at android.view.ViewGroup.drawChild(ViewGroup.java:1646) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) at android.view.View.buildDrawingCache(View.java:6640) at android.view.View.getDrawingCache(View.java:6428) at android.view.ViewGroup.drawChild(ViewGroup.java:1571) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) at android.widget.AbsListView.dispatchDraw(AbsListView.java:1666) at android.widget.ListView.dispatchDraw(ListView.java:3215) at android.view.View.draw(View.java:6986) at android.widget.AbsListView.draw(AbsListView.java:3048) at android.view.ViewGroup.drawChild(ViewGroup.java:1646) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) at android.view.ViewGroup.drawChild(ViewGroup.java:1644) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) at android.view.ViewGroup.drawChild(ViewGroup.java:1644) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) at android.view.ViewGroup.drawChild(ViewGroup.java:1644) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) at android.view.ViewGroup.drawChild(ViewGroup.java:1644) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) at android.view.ViewGroup.drawChild(ViewGroup.java:1644) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) at android.view.View.draw(View.java:6883) at android.support.v4.view.ViewPager.draw(ViewPager.java:1259) at android.view.ViewGroup.drawChild(ViewGroup.java:1646) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) at android.view.ViewGroup.drawChild(ViewGroup.java:1644) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) at android.view.View.draw(View.java:6883) at android.view.ViewGroup.drawChild(ViewGroup.java:1646) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) at android.view.ViewGroup.drawChild(ViewGroup.java:1644) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) at android.view.ViewGroup.drawChild(ViewGroup.java:1644) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) at android.view.ViewGroup.drawChild(ViewGroup.java:1644) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) at android.view.View.draw(View.java:6883) at android.widget.FrameLayout.draw(FrameLayout.java:357) at android.view.ViewGroup.drawChild(ViewGroup.java:1646) at me.imid.swipebacklayout.lib.SwipeBackLayout.drawChild(SwipeBackLayout.java:405) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) at android.view.ViewGroup.drawChild(ViewGroup.java:1644) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373) at android.view.View.draw(View.java:6883) at android.widget.FrameLayout.draw(FrameLayout.java:357) at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1921) at android.view.ViewRoot.draw(ViewRoot.java:1526) at android.view.ViewRoot.performTraversals(ViewRoot.java:1262) at android.view.ViewRoot.handleMessage(ViewRoot.java:1863) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3687) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636) at dalvik.system.NativeStart.main(Native Method)

    opened by jiahui90 8
  • how to add as dependency?

    how to add as dependency?

    I'm using Eclipse with ADT, how can I add this project as dependency?

    I've tried importing the library folder as an Android project into Eclipse, and then add this project into Java build path as projects. But it seems to be wrong.

    Thanks in advance.

    opened by westlinkin 7
  • ArrayIndexOutOfBoundsException when combine chrisbanes/PhotoView and SwipeBackLayout

    ArrayIndexOutOfBoundsException when combine chrisbanes/PhotoView and SwipeBackLayout

    Exception stack is

            java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
            at me.imid.swipebacklayout.lib.ViewDragHelper.shouldInterceptTouchEvent(ViewDragHelper.java:1084)
            at me.imid.swipebacklayout.lib.SwipeBackLayout.onInterceptTouchEvent(SwipeBackLayout.java:277)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1851)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2205)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1948)
            at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1970)
            at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1410)
            at android.app.Activity.dispatchTouchEvent(Activity.java:2509)
            at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1912)
            at android.view.View.dispatchPointerEvent(View.java:7333)
            at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3239)
            at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3184)
            at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4237)
            at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4216)
            at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4308)
            at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:171)
            at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
            at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:163)
            at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:4287)
            at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:4327)
            at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
            at android.view.Choreographer.doCallbacks(Choreographer.java:555)
            at android.view.Choreographer.doFrame(Choreographer.java:523)
            at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
            at android.os.Handler.handleCallback(Handler.java:615)
            at android.os.Handler.dispatchMessage(Handler.java:92)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:4866)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
            at dalvik.system.NativeStart.main(Native Method)
    
    
    opened by djj0809 6
  • NullPointerException when Activity finished

    NullPointerException when Activity finished

    set layerType to ViewCompat.LAYER_TYPE_NONE in SwipeBackLayout$ViewDragCallback.onViewDragStateChanged(int) causes this problem.

    you can comment out following lines to avoid crash.

            if (state == ViewDragHelper.STATE_IDLE) {
                ViewCompat.setLayerType(SwipeBackLayout.this, ViewCompat.LAYER_TYPE_NONE, null);
            } else if (state == ViewDragHelper.STATE_SETTLING) {
                ViewCompat.setLayerType(SwipeBackLayout.this, ViewCompat.LAYER_TYPE_HARDWARE, null);
            }
    
    opened by mariotaku 5
  • Full screen swipe back

    Full screen swipe back

    This pull request adds option to make it possible to start swipe back gesture from within the whole activity via setFullScreenSwipeEnabled(boolean) function.

    Swiping left and right works correctly but I was unable to make it work with swipe bottom or top as these weren't working even without my changes.

    opened by Tunous 4
  • Swipe back with Navigation Component

    Swipe back with Navigation Component

    Hello, i have an app designed by navigation component, my app navigates between fragments by navController.navigate() and navController.popBackStack(). Now i want to make a feature that user can swipe to back between current fragment and previous fragment but i didn't have an idea. How can i do it?

    opened by baonq-2356 1
  • 滑动返回触发后,又取消滑动返回,退出动画会失效

    滑动返回触发后,又取消滑动返回,退出动画会失效

    版本是: me.imid.swipebacklayout.lib:library:1.3.0 退出的动画: @Override public void finish() { super.finish(); overridePendingTransition(R.anim.tran_enter_out, R.anim.tran_exit_out); } R.anim.tran_enter_out代码:

    R.anim.tran_exit_out代码: 如果触发侧滑返回(从左边向右轻微拖动,然后再取消)只有R.anim.tran_exit_out的代码块会被执行到,R.anim.tran_enter_out不会执行,如果不触发侧滑返回,则两个都会执行到 测试环境: oppoR15真机,模拟器都会必现
    opened by leeyushi 3
  • Caused by: java.lang.ClassCastException: android.support.v7.widget.AppCompatTextView cannot be cast to me.imid.swipebacklayout.lib.SwipeBackLayout

    Caused by: java.lang.ClassCastException: android.support.v7.widget.AppCompatTextView cannot be cast to me.imid.swipebacklayout.lib.SwipeBackLayout

    开发中切换分支报过,但是重新编译就好了,这次线上直接报了,Caused by: java.lang.ClassCastException: android.support.v7.widget.AppCompatTextView cannot be cast to me.imid.swipebacklayout.lib.SwipeBackLayout

    opened by SelfImprLYJ 1
Owner
ike_w0ng
ike_w0ng
SwipeBack is an android library that can finish a activity by using gesture.

SwipeBack SwipeBack is a android library that can finish a activity by using gesture. You can set the swipe direction,such as left,top,right and botto

Eric 1.7k Nov 21, 2022
Visual back-port of the rotating drawer-to-arrow drawable from Android L

DrawerArrowDrawable A simple drawable backport of the new drawer-indicator/back-arrow rotating drawable from the upcoming Android L. License Copyright

Chris Renke 827 Nov 25, 2022
Easy, flexible and powerful Swipe Layout for Android

SwipeRevealLayout A layout that you can swipe/slide to show another layout. Demo Overview Drag mode Drag mode normal: Drag mode same_level: Features F

Chau Thai 1.5k Jan 4, 2023
The Most Powerful Swipe Layout!

Android Swipe Layout ![Gitter](https://badges.gitter.im/Join Chat.svg) This is the brother of AndroidViewHover. One year ago, I started to make an app

代码家 12.3k Dec 28, 2022
swipe display drawer with flowing & bouncing effects.

FlowingDrawer swipe right to display drawer with flowing effects. Download Include the following dependency in your build.gradle file. Gradle: rep

mxn 2.6k Jan 3, 2023
You don’t want your apps look and feel boring, do you? Add some bubbles!

#BubbleAnimationLayout Say hello to Bubble Animation Layout for Android by Cleveroad You don’t want your apps look and feel boring, do you? Add some b

Cleveroad 576 Nov 23, 2022
This library provides a simple way to add a draggable sliding up panel (popularized by Google Music and Google Maps) to your Android application. Brought to you by Umano.

Note: we are not actively responding to issues right now. If you find a bug, please submit a PR. Android Sliding Up Panel This library provides a simp

Umano: News Read To You 9.4k Dec 31, 2022
It's an Android library that allows you to use Layout as RadioButton or CheckBox.

Android - CompoundLayout It's an Android library that allows you to use Layout as RadioButton or CheckBox. The librarie is Android 14+ compatible. Gra

null 483 Nov 25, 2022
A library that easily allows you to mask layouts/viewgroups

Maskable Layout Overview ======================= The Maskable Layout is a simple framelayout that allows you to easily mask views and viewgroups. You

Christophe Smet 654 Dec 2, 2022
A 3D Layout for Android,When you use it warp other view,it can became a 3D view,一秒让你的view拥有3D效果!

ThreeDLayout A 3D Layout,When you use it warp other view,it can became a 3D view 中文文档 preview USAGE 1.compile library allprojects { repositories {

androidwing 490 Oct 27, 2022
ConstraintLayout is an Android layout component which allows you to position and size widgets in a flexible way

ConstraintLayout is a layout manager for Android which allows you to position and size widgets in a flexible way. It's available for both the Android view system and Jetpack Compose.

Android Jetpack 970 Jan 6, 2023
VoronoiView is a view (ViewGroup) that allows you to add and display views inside Voronoi diagram regions.

Vorolay VoronoiView is a view (ViewGroup) that allows you to add and display views inside Voronoi diagram regions. [Voronoi diagram] (https://en.wikip

Daniil Jurjev 918 Dec 4, 2022
This assignment gives you basically a post list and its detail with comments.🚀

Android Assignment ?? Description This assignment gives you basically a post list and its detail with comments. ?? Features Users can see random post

Okan AYDIN 31 Dec 20, 2022
Android library used to create an awesome Android UI based on a draggable element similar to the last YouTube graphic component.

Draggable Panel DEPRECATED. This project is not maintained anymore. Draggable Panel is an Android library created to build a draggable user interface

Pedro Vicente Gómez Sánchez 3k Jan 5, 2023
Bubbles for Android is an Android library to provide chat heads capabilities on your apps. With a fast way to integrate with your development.

Bubbles for Android Bubbles for Android is an Android library to provide chat heads capabilities on your apps. With a fast way to integrate with your

Txus Ballesteros 1.5k Jan 2, 2023
Android library used to create an awesome Android UI based on a draggable element similar to the last YouTube New graphic component.

Please switch to DragView, for the best support, thank you DraggablePanel Download allprojects { repositories { ... maven { url 'https://jitp

Hoàng Anh Tuấn 103 Oct 12, 2022
FixedHeaderTableLayout is a powerful Android library for displaying complex data structures and rendering tabular data composed of rows, columns and cells with scrolling and zooming features. FixedHeaderTableLayout is similar in construction and use as to Android's TableLayout

FixedHeaderTableLayout is a powerful Android library for displaying complex data structures and rendering tabular data composed of rows, columns and cells with scrolling and zooming features. FixedHeaderTableLayout is similar in construction and use as to Android's TableLayout

null 33 Dec 8, 2022
A very simple arc layout library for Android

ArcLayout A very simple arc layout library for Android. Try out the sample application on the Play Store. Usage (For a working implementation of this

ogaclejapan 1.4k Dec 26, 2022