支持手势滑动关闭Activity,支持上下左右四个方向。在滑动关闭时,会像微信一样显示上一个页面和一条阴影
鼠标操作不便,所以截图中有卡顿,但真机效果还是不错的。
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<!-- 必须得设置下面两个属性,否则看不到上一个页面-->
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style>
public class NormalActivity extends SwipeBackActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_normal);
setDragEdge(SwipeBackLayout.DragEdge.BOTTOM);
}
}
public class MainActivity extends SwipeBackActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//关闭手势
canSwipeBack = false;
setContentView(R.layout.activity_main);
}
}