Android 滑动返回Activity的实现代码
近来玩微信的时候偶然发现,向左滑动朋友圈竟然可以返回主页,故引起兴趣特研究
代码很简洁
package com.example.wyj.cainiaoshopping.activity; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import com.example.wyj.cainiaoshopping.R; import me.imid.swipebacklayout.lib.SwipeBackLayout; import me.imid.swipebacklayout.lib.app.SwipeBackActivity; public class SwiftActivity extends SwipeBackActivity { private SwipeBackLayout mSwipeBackLayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_swift); mSwipeBackLayout = getSwipeBackLayout(); int edgeFlag = SwipeBackLayout.EDGE_LEFT; mSwipeBackLayout.setEdgeTrackingEnabled(edgeFlag); // saveTrackingMode(edgeFlag); } }
绑定远程仓库
compile 'me.imid.swipebacklayout.lib:library:1.0.0'
另外Activity的主题也要设置
<item name="Android:windowIsTranslucent">true</item>
最后继承使用即可
以上就是关于Android 滑动返回Activity的实例详解,本站有关Android 的开发文章还有很多,希望大家搜索查阅,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!