Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

overridePendingTransition duration is ignored

I'm using overridePendingTransition to set my own activity transition. Everything works fine except that I cannot change to duration of the animation, it is ignored.

slide_down.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/accelerate_decelerate_interpolator">

    <translate
        android:duration="2000"
        android:fromYDelta="0"
        android:toYDelta="100%p"
        android:zAdjustment="top"/>

</set>

stay.xml

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="2000"
    android:fromYDelta="0%p"
    android:toYDelta="0%p"
    android:zAdjustment="top"/>

The duration is set to 2000 ms but the animation is still just a fraction of a second long. Even changing it to an extreme value like 10000 does nothing.

If I change the animations in Developer options in settings, the animation duration corresponds to the given settings.

Java code for reference:

MainActivity.java

public void games(View view){

    startActivity(new Intent(MainActivity.this, GamesActivity.class));
    overridePendingTransition(R.anim.slide_up, R.anim.stay);


}

Anyone that has an idea?

like image 361
fredthemugwump Avatar asked Oct 29 '22 21:10

fredthemugwump


1 Answers

It's been a long time since you asked this but I just experienced this.

Try doing a clean build. That fixed it for me. Looks like Instant Run causes the animations to not be updated on every run.

like image 93
Chaitanya Nettem Avatar answered Nov 15 '22 06:11

Chaitanya Nettem