I have a requirement that when i call next activity i want to do transitions of layouts. The current layout should move to the left and next or the new view should move right like in an HDFC Mobile Banking application https://play.google.com/store/apps/details?id=com.snapwork.hdfc&feature=search_result#?t=W251bGwsMSwyLDEsImNvbS5zbmFwd29yay5oZGZjIl0..
Asked
Active
Viewed 1,647 times
2 Answers
2
Use overridePendingTransition to change the transition right after/before calling finish or startActivity.

Gabe Sechan
- 90,003
- 9
- 87
- 127
2
res/anim/slide_in_left.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="-100%p" android:toXDelta="0" android:duration="400" />
</set>
res/anim/slide_out_left.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="0" android:toXDelta="-100%p" android:duration="400" />
</set>
MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
startActivity(new Intent(getApplicationContext(), Activity2.class));
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left);
}
});
}
Activity2.java
@Override
public void onBackPressed() {
super.onBackPressed();
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left);
}

Hamze Sheyikh Shoaei
- 803
- 8
- 10