This article shows the method of Android to add animation effects by switching the Activity interface in an example form, which is of good reference value for Android programmers. The specific methods are as follows:
Those who understand Android programming should know that after Android 2.0, there is overridePendingTransition(), which has two parameters, one is the exit of the previous activity and the entry of the other activity.
Now take a look at the following sample code:
@Override public void onCreate(Bundle savedInstanceState) { (savedInstanceState); setContentView(); new Handler().postDelayed(new Runnable() { @Override public void run() { Intent mainIntent = new Intent(, ); (mainIntent); (); overridePendingTransition(, ); } }, 3000); }
The above code is just part of the splash screen.
getWindow().setWindowAnimations(int);
This is not as good as this one, but it is OK.
Achieve fading effect:
overridePendingTransition(.fade_in,.fade_out);
Slide in from left to right effect:
overridePendingTransition(.slide_in_left,.slide_out_right);
Implement zoomin and zoomout, that is, the effect of entering and exiting an iPhone similar to:
overridePendingTransition(, );
Create a new file:
<?xml version="1.0" encoding="utf-8"?> <set xmlns:Andro Android:interpolator="@android:anim/decelerate_interpolator"> <scale Android:fromXScale="2.0" android:toXScale="1.0" Android:fromYScale="2.0" android:toYScale="1.0" Android:pivotX="50%p" android:pivotY="50%p" Android:duration="@android:integer/config_mediumAnimTime" /> </set>
Create a new file:
<?xml version="1.0" encoding="utf-8"?> <set xmlns:Andro Android:interpolator="@android:anim/decelerate_interpolator" Android:zAdjustment="top"> <scale Android:fromXScale="1.0" android:toXScale=".5" Android:fromYScale="1.0" android:toYScale=".5" Android:pivotX="50%p" android:pivotY="50%p" Android:duration="@android:integer/config_mediumAnimTime" /> <alpha Android:fromAlpha="1.0" android:toAlpha="0" Android:duration="@android:integer/config_mediumAnimTime"/> </set>
I believe that the examples described in this article have certain reference value for everyone's Android programming design.