滑动关闭当前Activity

一、git地址:https://github.com/ikew0ng/SwipeBackLayout

二、BaseActivity 继承 SwipeBackActivity:

public class BaseActivity extends SwipeBackActivity {
 
    private SwipeBackLayout mSwipeBackLayout;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mSwipeBackLayout = getSwipeBackLayout();
        //设置滑动方向,可设置EDGE_LEFT, EDGE_RIGHT, EDGE_ALL, EDGE_BOTTOM
        mSwipeBackLayout.setEdgeTrackingEnabled(SwipeBackLayout.EDGE_LEFT);
        //mSwipeBackLayout.setEdgeSize(200);//滑动删除的效果只能从边界滑动才有效果,如果要扩大touch的范围,可以调用这个方法
    }
}

需要在清单文件中,AppTheme 主题上,加上这个属性,要不然activity的背景应该是黑色的,很难看:
	true

你可能感兴趣的:(Android)