Mainactivity is as follows:
Package com.cn. testanimation; import android. OS. bundle; import android. app. activity; import android. view. menu; import android. view. animation. animation; import android. view. animation. animation. animationlistener; import android. view. animation. animationutils; import android. widget. imageview; import android. widget. toast; public class mainactivity extends activity {private imageview; private animation welcomeanimation; @ override public void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. activity_main); imageview = (imageview) findviewbyid (R. id. imageview); welcomeanimation = animationutils. loadanimation (this, R. anim. welcome); imageview. startanimation (welcomeanimation); welcomeanimation. setanimationlistener (New animationlistener () {public void onanimationstart (animation) {} public void animation (animation) {} public void onanimationend (animation) {/tip: when the animation ends, use intent to jump to the next activitytoast. maketext (getapplicationcontext (), "prepare to jump to the next page", 0 ). show () ;}}) ;}@ override public Boolean oncreateoptionsmenu (menu) {getmenuinflater (). inflate (R. menu. activity_main, menu); Return true ;}}
Main. XML is as follows:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <ImageView android:id="@+id/imageView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/ic_launcher" /></RelativeLayout>
The welcome. xml animation is as follows:
<? XML version = "1.0" encoding = "UTF-8"?> <! -- Alpha = 1.0 indicates opacity, alpha = 0.0 indicates transparency --> <set xmlns: Android = "http://schemas.android.com/apk/res/android" Android: interpolator = "@ Android: anim/decelerate_interpolator"> <Alpha Android: duration = "4000" Android: fromalpha = "0.0" Android: toalpha = "1.0"/> </set>