1. Use tweenAnimation animation scenarios:
1. asynchronously load images
2. activity jump
3. Welcome Page
The following is an animation switching code between activities:
StartActivity (new Intent (MainActivity. this, SecondActivity. class); overridePendingTransition (R. anim. fade, R. anim. hold); // overridePendingTransition is used to define the animation for switching between activities. // The animation displayed after the fade activity. hold the animation that disappears before it. If it is (0, 0), there will be no animation.
The following is the code for implementing the animation of a control:
imageView.startAnimation(AnimationUtils.loadAnimation(this, R.anim.set));
The following code shows how to implement the wave animation in APIdemo:
650) this. length = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/103A33Q5-0.jpg "title =" qq 30901120115.jpg "width =" 250 "height =" 352 "border =" 0 "hspace =" 0 "vspace =" 0 "style =" width: 250px; height: 352px; "/>
Layout XML code:
<GridView xmlns:android="http://schemas.android.com/apk/res/android" android:layoutAnimation="@anim/layout_wave_scale" android:id="@+id/grid" android:layout_width="match_parent" android:layout_height="match_parent" android:verticalSpacing="10dp" android:horizontalSpacing="10dp" android:numColumns="auto_fit" android:columnWidth="60dp" android:stretchMode="columnWidth" android:gravity="center" ></GridView>
Layout_wave_scale code in the anim directory:
<GridLayoutAnimation xmlns: android = "http://schemas.android.com/apk/res/android" android: rowDelay = "75%" // row delay android: columnDelay = "0%" // column delay android: direpripriority = "none" android: animation = "@ anim/wave_scale"/> // gridLayoutAnimation indicates
Wave_scale code in the anim directory:
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator"> <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="100" /> <scale android:fromXScale="0.5" android:toXScale="1.5" android:fromYScale="0.5" android:toYScale="1.5" android:pivotX="50%" android:pivotY="50%" android:duration="200" /> <scale android:fromXScale="1.5" android:toXScale="1.0" android:fromYScale="1.5" android:toYScale="1.0" android:pivotX="50%" android:pivotY="50%" android:startOffset="200" android:duration="100" /></set>
The Code is as follows:
Public class LayoutAnimation6 extends Activity {@ Override protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); loadApps (); setContentView (R. layout. activity_main); GridView grid = (GridView) findViewById (R. id. grid); grid. setAdapter (new external adapter ();} private List <ResolveInfo> mApps; // The ResolveInfo class is obtained by parsing the intent corresponding to IntentFilter. // It partially corresponds to the information collected from the <intent> tag of AndroidManifest. xml. Private void loadApps () {Intent mainIntent = new Intent (Intent. ACTION_MAIN, null); mainIntent. addCategory (Intent. CATEGORY_LAUNCHER); // It parses the <Intent-filter> tag to get all apps that meet the filter conditions mApps = getPackageManager (). queryIntentActivities (mainIntent, 0);} public class extends adapter extends BaseAdapter {public View getView (int position, View convertView, ViewGroup parent) {ImageView I = new ImageView (LayoutAnimation6.this ); resolveInfo info = mApps. get (position % mApps. size (); // info. activityInfo. loadIcon gets the icon I. setImageDrawable (info. activityInfo. loadIcon (getPackageManager (); // FIT_CENTER: scales up or down an image to the width of the View, and center the image to I. setScaleType (ImageView. scaleType. FIT_CENTER); final int w = (int) (36 * getResources (). getDisplayMetrics (). density + 0.5f); I. setLayoutParams (new GridView. layoutParams (w, w); return I;} public final int getCount () {return Math. min (32, mApps. size ();} public final Object getItem (int position) {return mApps. get (position % mApps. size ();} public final long getItemId (int position) {return position ;}}}
Note:
1) alpha: Transparency android: fromAlpha = "0.0"
Android: toAlpha = "1.0"
Android: duration= "3000"
2) rotate: rotate android: fromDegrees = "0"
Android: toDegrees = "360" Rotation Angle
Android: centers Tx = "50%" centered on the midpoint
Android: Ty = "50%"
Android: duration = "3000">
3) translate: android: fromXDelta = "-200"
Android: fromYDelta = "-200"
Android: toXDelta = "0" returns to the original point
Android: toYDelta = "0"
Android: duration= "3000"
Android: interpolator = "@ android: anim/accelerate_interpolator" Accelerator>
4) scale: scale android: Small Tx = "50%"
Android: Ty = "50%"
Android: fromXScale = "0.2" ratio
Android: toXScale = "1"
Android: fromYScale = "0.2"
Android: toYScale = "1"
Android: duration = "3000">
5) set: the above four sets
android:startOffset=
"200" // executed in 200 milliseconds
This article is from the "wangcuijing" blog, please be sure to keep this source http://wangcuijing.blog.51cto.com/7233352/1286566