Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

start activity with left to right mode

I am facing a problem .

I have three activities and i need to start new activity with slide left.

Activity1  Activity2  Activity3 

means enter image description here

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.

like image 429
Monty Avatar asked May 20 '13 11:05

Monty


People also ask

How do I start the same activity again on android?

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.

What is transition animation in Android?

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.


1 Answers

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); } 
like image 113
Med Besbes Avatar answered Sep 19 '22 05:09

Med Besbes