问题
My Activity Successfully slide in android 4.1 from Activity A to B using animation
**inamation.xml**
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="100%"
android:toXDelta="0%"
android:duration="600" />
</set>
and
outanimation.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="100%"
android:toXDelta="0%"
android:duration="600" />
</set>
and in activity A i used overidding pending transition as shown below:
A.this.overridePendingTransition(R.anim.outanimation,R.anim.inanimation);
as said earlier this works fine on android 4 and above platform but when i test it on android 2.3 platform, Activity A to B gets android default activity animation.
how can i run my activity to slide left to right and right to left which is compatible with 2.2 and above.
Is there a way to set animation between two activities programmatically ?
UPDATE
The problem was that the device, at least in the case of Samsung Galaxy, has to have animations enabled for this to work. This can be done in the settings menu.
Do you know how to activate all animation from settings Menu in Android ?
回答1:
For Android Slide in and out animation, I have use following code.
Activity A :
Intent intnt = new Intent(SplashScreen.this,
CustomTabActivity.class);
startActivity(intnt);
overridePendingTransition(R.anim.slide_in_left,
R.anim.slide_out_left);
finish();
slide_in_left.xml
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_longAnimTime"
android:fromXDelta="100%p"
android:toXDelta="0%p" />
slide_out_left.xml
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_longAnimTime"
android:fromXDelta="0"
android:toXDelta="-100%p" />
来源:https://stackoverflow.com/questions/16477027/android-slide-in-and-out-animation-issue