swipebacklayout的用法

丁善
2023-12-01

1.在buildgrade里添加

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

2.让activity继承

SwipeBackActivity

3.在activity添加

  private SwipeBackLayout mSwipeBackLayout;
// 可以调用该方法,设置是否允许滑动退出
        setSwipeBackEnable(true);
        mSwipeBackLayout = getSwipeBackLayout();
        // 设置滑动方向,可设置EDGE_LEFT, EDGE_RIGHT, EDGE_ALL, EDGE_BOTTOM
        mSwipeBackLayout.setEdgeTrackingEnabled(SwipeBackLayout.EDGE_LEFT);
        // 滑动退出的效果只能从边界滑动才有效果,如果要扩大touch的范围,可以调用这个方法
        mSwipeBackLayout.setEdgeSize(300);

 

 类似资料: