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 bottom.
dependencies {
compile 'com.github.liuguangqiang.swipeback:library:1.0.2@aar'
}
<dependency>
<groupId>com.github.liuguangqiang.swipeback</groupId>
<artifactId>library</artifactId>
<version>1.0.2</version>
<type>aar</type>
</dependency>
SwipeBackActivity is a base activity for using this library more easier.This Activity will help us to show a shadow.
public class CommonActivity extends SwipeBackActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_common);
setDragEdge(SwipeBackLayout.DragEdge.LEFT);
}
}
SwipeBackLayout must contains only one direct child.
<com.liuguangqiang.swipeback.SwipeBackLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipeBackLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- SwipeBackLayout must contains only one direct child -->
</com.liuguangqiang.swipeback.SwipeBackLayout>
<style name="Theme.Swipe.Back" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
You can set DragEdge to change the swipe direction.
public enum DragEdge {
LEFT,
TOP,
RIGHT,
BOTTOM
}
SwipeBackLayout must contains only one direct child.
Such as:
Copyright 2015 Eric Liu
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.
1. 知识背景 项目中常用的侧滑返回控件大部分都是通过内部封装ViewDragHelper进行View拖拽实现的,而采用ViewDragHelper的方式必然会带来另外两个问题: Q1:什么样的右滑才是退出界面,而不是滑动界面内容? A1:ViewDragHelper传入参数View作为ControllerView,通过改变它的布局参数实现拖拽效果。为了达到Activity右滑返回的能力,那么Co
SwipeBack侧滑开源组件冲突问题处理 SwipeBack github地址:https://github.com/zhibuyu/SwipeBackDemo 智能手机的大屏化,使得单手操作和侧滑返回这两个功能成为了移动开发中常见的需求,本文说的就是侧滑开源组件SwipeBack在常见布局中的一些冲突问题。 常见问题: Editext滑动冲突 RecyclerView滑动冲突 1.Editex
本文向大家介绍Android中SwipeBack实现右滑返回效果,包括了Android中SwipeBack实现右滑返回效果的使用技巧和注意事项,需要的朋友参考一下 现在有很多App支持右滑返回,比如知乎,效果比较赞。 于是自己对Activity和Fragment进行了继承,派生出SwipeBackActivity和SwipeBackFragment,用于对这种效果的实现,也就是只要继承这两个类就可
SwipeBackLayout 是一个支持屏幕上下左右滑动返回上层 Activity, 关闭当前 Activity, 类似简书 App。 效果图: 示例代码: public class DemoActivity extends SwipeBackActivity implements View.OnClickListener { private int[] mBgColors; pri