简体   繁体   中英

Android Slide in and out animation issue

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 ?

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" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM