Android的Frame动画介绍

来源:互联网 发布:泰州数据大厦 魏主任 编辑:程序博客网 时间:2024/05/16 06:52

一、Frame Animation

资源文件:res/drawable/filename.xml

<?xml version="1.0" encoding="utf-8"?>
<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" />
</animation-list>

代码:

 @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        TextView textView = (TextView) this.findViewById(R.id.textView);
        textView.setBackgroundResource(R.drawable.frame);
        final AnimationDrawable animationDrawable = (AnimationDrawable) textView.getBackground();
        
        getMainLooper().myQueue().addIdleHandler(new MessageQueue.IdleHandler() {
public boolean queueIdle() {
animationDrawable.start();//开启动画
return false;
}
}); 


原创粉丝点击