For most of the android apps we do have
multiple activities and when we start another activity either we get no
animation (in older devices) or a left-right translation. It is not so
cool for a stylish app.
startActivity(new Intent(this, NewActivity.class));
overridePendingTransition(R.anim.push_left_in,R.anim.push_out_up);
These two parameters are resource IDs for animations
defined with XML files (one for each animation). These files have to be placed
inside the app’s res/anim folder.
push_left_in.xml:-
push_out_up.xml:-
The first xml code makes slides the View diagonally. The second one slides the View to the left and then up.
push_left_in.xml:-
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="100%p" android:toXDelta="0" android:duration="300"/>
<alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="300" />
</set>
push_out_up.xml:-
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="100%p" android:fromYDelta="100%p" android:toXDelta="0" android:toXDelta="0" android:duration="300"/>
</set>
The first xml code makes slides the View diagonally. The second one slides the View to the left and then up.
No comments:
Post a Comment