1. First layout the file in aime_activity.xml
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" ><ImageView android:id="@+id/Img_center" android:layout_width="50dp" android:layout_height="50dp" android:layout_centerHorizontal="true" android:layout_centerVertical="true"/></RelativeLayout >
2. Create an anim. xml Frame Animation File
<?xml version="1.0" encoding="utf-8"?><animation-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@android:drawable/star_big_off" android:duration="50"/> <item android:drawable="@android:drawable/star_big_on" android:duration="50"/></animation-list>
Note: The duration Attribute indicates the display time of each item.
3. java File
Img1=(ImageView)this.findViewById(R.id.Img_center);Img1.setBackgroundResource(R.drawable.login_img);Img1.setVisibility(ImageView.VISIBLE);AnimationDrawable frameAnimation = (AnimationDrawable)Img1.getBackground();frameAnimation.stop();frameAnimation.start();
This article is from the "7603943" blog, please be sure to keep this source http://7613943.blog.51cto.com/7603943/1284321