SwipeBackLayout 是一个支持屏幕上下左右滑动返回上层 Activity, 关闭当前 Activity, 类似简书 App。
效果图:
示例代码:
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); } }); }