博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Animation(四)
阅读量:7004 次
发布时间:2019-06-27

本文共 1080 字,大约阅读时间需要 3 分钟。

三、Frame-byFrame动画

Activity代码:

public class AnimationFrameByFrameActivity extends Activity {

    private ImageView img=null;

    private Button btn=null;

    @Override

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);

        img=(ImageView)findViewById(R.id.img);

        btn=(Button)findViewById(R.id.btn);

        btn.setOnClickListener(new OnClickListener() {

           

           public void onClick(View v) {

              //逐帧动画效果

              // TODO Auto-generated method stub

              img.setBackgroundResource(R.drawable.animimg);

              AnimationDrawable anim=(AnimationDrawable)img.getBackground();

              anim.start();

           }

       });

    }

}

Animimg.xml代码:

<?xmlversion="1.0"encoding="utf-8"?>

<animation-listxmlns:android="http://schemas.android.com/apk/res/android"

android:oneshot="false">

<itemandroid:drawable="@drawable/a"android:duration="500"/>

<itemandroid:drawable="@drawable/b"android:duration="500"/>

<itemandroid:drawable="@drawable/c"android:duration="500"/>

<itemandroid:drawable="@drawable/d"android:duration="500"/>

</animation-list>

 

转载于:https://www.cnblogs.com/itfenqing/archive/2011/08/29/4429508.html

你可能感兴趣的文章