项目地址:ikew0ng/SwipeBackLayout: An Android library that help you to build app with swipe back gesture.
I make it point to add: P)
SwipeBackXActivity.java
public abstract class SwipeBackXActivity extends SwipeBackActivity { protected abstract int getStatusBarColorId(); protected boolean makeStatusBarContentBlack() { return false; } @Override protected void onPostCreate (Bundle savedInstanceState) { super .onPostCreate (savedInstanceState); setStatusBarToTransparent(); setSystemUiVisibilityForDecorView(); initContentView (); } private void setStatusBarToTransparent() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().setStatusBarColor(Color.TRANSPARENT); } } private void setSystemUiVisibilityForDecorView() { int visibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; if (makeStatusBarContentBlack()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { visibility |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; } } getWindow().getDecorView().setSystemUiVisibility(visibility); } private void initContentView() { ViewGroup content = getWindow().getDecorView().findViewById(android.R.id.content); content.setFitsSystemWindows(true); int height = StatusBarUtils.getHeight(this); content.getChildAt(0).setPadding(0, height, 0, 0); View statusBar = new View(this); int id = getStatusBarColorId(); if (id != 0) { statusBar.setBackgroundColor(getResources().getColor(id)); } content.addView(statusBar, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, StatusBarUtils.getHeight(this))); } }
SwipeBackXActivity avoid the layout and the status bar of the "tear" effect
The figure below is what I call a tearing effect
As micro-channel effect SwipeBackXActivity
SwipeBackXActivity supplementary reference from: DyncKathline / SwipeBackLayout: Immersive sliding shut Activity