I am facing a problem .
I have three activities and i need to start new activity with slide left.
Activity1 Activity2 Activity3
means
when i click to button new activity should not display directly like what android behavior .
i want new activity come from right side and display on current screen.
anyone can provide me guidance. This is animation or anything else.
If you just want to reload the activity, for whatever reason, you can use this. recreate(); where this is the Activity. This is never a good practice. Instead you should startActivity() for the same activity and call finish() in the current one.
Android's transition framework allows you to animate all kinds of motion in your UI by simply providing the starting layout and the ending layout.
I'll try to help you with the following example:
res/anim/trans_left_in.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="@android:integer/config_longAnimTime"/> </set>
res/anim/trans_left_out.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="@android:integer/config_longAnimTime"/> </set>
res/anim/trans_right_in.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="@android:integer/config_longAnimTime"/> </set>
res/anim/trans_right_out.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="@android:integer/config_longAnimTime"/> </set>
src/Activity2
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_traces); overridePendingTransition(R.anim.trans_left_in, R.anim.trans_left_out); ...} @Override public void onBackPressed() { super.onBackPressed(); overridePendingTransition(R.anim.trans_right_in, R.anim.trans_right_out); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With