Lets assume you have an Activity called A1 and A1 has a table/ listView in it.
When you tap on a row in A1 we want to display another Activity called A2.
From A1 to A2 we need the following animation.
- Lets say A1 has 10 rows and user taps on 5th row.
- The portion of screen till 5th row has to move up.
- The portion of screen from 6th row has to move down.
- A2 has to fade in from center as the above 2 animations happen.
Since Animations are supported from Android OS version 3.0 , I am checking if the Build version of the device and if it is less than 3.0 then I use a library called nineoldandroids's API for animations else I use android default Animation API to do the same.
In our application, the third animation is starting a new activity with a fade-in animation and since each activity has its own life cycle and the moment new activity is started with fade animation the currently running animation of the first activity ( portion of the screen moving up and portion of the screen moving down) gets a small lag.
To avoid the lag, its has been the mentioned that the we should do the following,
- Not to initiate animations onCreate, onStart, onResume.
- Initiate animations on user events such as onClick and hault user interaction until animation is complete.
- Not to aniamte more than 2 animations simultaneously
Kindly check my source code at: https://bitbucket.org/cynogn/animation