N Sharma
N Sharma

Reputation: 34507

Activity is taking too much time from bottom to top animation

I am working on demo application where I am looking to animate an activity from bottom to top.

MainActivity.java

Intent slideactivity = new Intent(MainActivity.this, SecondActivity.class);
startActivity(slideactivity);
overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);

slide_in_up.xml

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

slide_out_up.xml

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

Here I set only 100 milli seconds for animation but second activity is being started after at least 3-4 seconds.

SecondActivity.java

public class SecondActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);
    }
}

Upvotes: 0

Views: 356

Answers (2)

Antonios Tsimourtos
Antonios Tsimourtos

Reputation: 1672

Have you tried to clean build your project? Also, if you run it on the emulator sometimes it is laggy on animations, try it on a physical device. Code seems good! You should increase the duration though, 700 would be nice.

Upvotes: 0

Stepan Maksymov
Stepan Maksymov

Reputation: 2606

Second activity first is created and only then animated, you have delay coz you probably do too much tasks in onCreate / onStart / onResume of second activity. Try to remove all "hard" tasks to async tasks.

Upvotes: 1

Related Questions