在main.xml中
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView"
/>
</LinearLayout>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/girl_1" android:duration="200"/>
<item android:drawable="@drawable/girl_2" android:duration="200"/>
<item android:drawable="@drawable/girl_3" android:duration="200"/>
<item android:drawable="@drawable/girl_4" android:duration="200"/>
<item android:drawable="@drawable/girl_5" android:duration="200"/>
<item android:drawable="@drawable/girl_6" android:duration="200"/>
<item android:drawable="@drawable/girl_7" android:duration="200"/>
<item android:drawable="@drawable/girl_8" android:duration="200"/>
<item android:drawable="@drawable/girl_9" android:duration="200"/>
<item android:drawable="@drawable/girl_10" android:duration="200"/>
<item android:drawable="@drawable/girl_11" android:duration="200"/>
<item android:drawable="@drawable/girl_1" android:duration="200"/>
<item android:drawable="@drawable/girl_1" android:duration="200"/>
</animation-list>
在MainActivity.java中
TextView textView = (TextView) this.findViewById(R.id.textView);
textView.setBackgroundResource(R.drawable.frame);//绑定Frame动画图形
final AnimationDrawable drawable = (AnimationDrawable) textView.getBackground();
getMainLooper().myQueue().addIdleHandler(new MessageQueue.IdleHandler() {
public boolean queueIdle() {
drawable.start();//启动动画
return false;
}
});
}
详解参考:http://www.cnblogs.com/obullxl/archive/2011/06/10/android-animation-frame-dance.html
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView"
/>
</LinearLayout>
在res下新建drawable文件夹,又在改文件夹下新建frame.xml和.gif动画
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/girl_1" android:duration="200"/>
<item android:drawable="@drawable/girl_2" android:duration="200"/>
<item android:drawable="@drawable/girl_3" android:duration="200"/>
<item android:drawable="@drawable/girl_4" android:duration="200"/>
<item android:drawable="@drawable/girl_5" android:duration="200"/>
<item android:drawable="@drawable/girl_6" android:duration="200"/>
<item android:drawable="@drawable/girl_7" android:duration="200"/>
<item android:drawable="@drawable/girl_8" android:duration="200"/>
<item android:drawable="@drawable/girl_9" android:duration="200"/>
<item android:drawable="@drawable/girl_10" android:duration="200"/>
<item android:drawable="@drawable/girl_11" android:duration="200"/>
<item android:drawable="@drawable/girl_1" android:duration="200"/>
<item android:drawable="@drawable/girl_1" android:duration="200"/>
</animation-list>
在MainActivity.java中
TextView textView = (TextView) this.findViewById(R.id.textView);
textView.setBackgroundResource(R.drawable.frame);//绑定Frame动画图形
final AnimationDrawable drawable = (AnimationDrawable) textView.getBackground();
getMainLooper().myQueue().addIdleHandler(new MessageQueue.IdleHandler() {
public boolean queueIdle() {
drawable.start();//启动动画
return false;
}
});
}
详解参考:http://www.cnblogs.com/obullxl/archive/2011/06/10/android-animation-frame-dance.html