Reputation: 4259
I am building an android app, and I want to be able to have a custom transition from one of the activities to another. when I press a button on the first activity I want it to reduce its size and go to the one of the corners of the screen until it disappears, and the second activity is called. Of course, during the resizing and moving the first activity, the second activity will begin to show itself (what I want to say is, during this time, I don't want to have a black screen underneath). Does someone have experience with this kind of stuff? I also want to note that I am building my app for API 3.0+ so it is ok to use newer functions and methods. Thx!
Upvotes: 3
Views: 6109
Reputation: 12745
You should be able to use a simple scale animation for this. In the second activity you can do something like:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
overridePendingTransition(R.anim.scale_from_corner, R.anim.scale_to_corner);
}
For the animations it'd be:
scale_to_corner.xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale android:fromYScale="1.0" android:toYScale="0"
android:fromXScale="1.0" android:toXScale="0"
android:duration="500"/>
</set>
and scale_from_corner.xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale android:fromYScale="0" android:toYScale="1.0"
android:fromXScale="0" android:toXScale="1.0"
android:duration="500" android:pivotX="100%"
android:pivotY="100%" />
</set>
This will make your first activity shrink into the top left corner while your second activity grows from the bottom right corner. If you want to change the point in which they grow from or shrink to, you can just change the pivotX and pivotY.
Upvotes: 14