Online Search slide off activity, are very similar, even if there is no complete demo, said integration is simple, and so you will know. Personal habits, before writing a blog like first
1. First import into your project in the form of a project
2. Then in the activity you want to slide into the integration swipebackactivity, note that as long as the integration is good, and nothing else you write, you can realize the slide-off. The following code is listed: Mainactivity.java
public class MainActivity extends AppCompatActivity {
private TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = (TextView) findViewById(R.id.text);
}
public void click(View view) {
if (view.getId() == R.id.button) {
startActivity(new Intent(MainActivity.this, SecondActivity.class));
} else {
startActivityForResult(new Intent(MainActivity.this, ThirdActivity.class), 1);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
String result = data.getStringExtra("result");
if (requestCode == 1 && resultCode == 0) {
textView.setText(result);
}
}
}
Secondactivity.java
public class SecondActivity extends SwipeBackActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
}
}
Thirdactivity.java
public class ThirdActivity extends SwipeBackActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_third);
}
@Override
public void dothingBeforeFinish() {//这里是你要返回一些数据个启动的那个Activity,你可以在此做操作
super.dothingBeforeFinish();
Intent intent = new Intent();
intent.putExtra("result", "来自ThirdActivity返回的值");
setResult(0, intent);
}
}
The code is not very simple, so it is easy to achieve an immersive slide-off. As for the slide-by activity status bar Why is it gray, because I wrote dead in swipebackactivity, you can modify this color.
Setupstatusbarview (ActivitycontentlayoutColor.) Parsecolor ("#cccccc")) ;
OK, here is the GitHub source code, like please start, fork. Https://github.com/DyncKathline/SwipeBackLayout
Reprint Please indicate the source, thank you!
From for notes (Wiz)
Minutes to teach you integrated immersive slide-off activity