SwipeBackLayout

介绍:

让activity具有滑动返回的效果 类似于ios的返回方式。还是比较流畅的。

运行效果:

使用说明:

1.将SwipeBackLayout添加进项目的依赖中

2.让activity继承SwipeBackActivity,可以通过getSwipeBackLayout()方法自定义SwipeBackLayout

3.在主题中设置<item name="android:windowIsTranslucent">true</item>

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);
            }
        });
    }
...
已下载
0