Android动画解析2-帧动画实现

来源:互联网 发布:数据透视表应用大全 编辑:程序博客网 时间:2024/05/15 02:36

帧动画在Android动画中是比较简单的,是按照一定顺序播放一组图片,像快速的PPT一样,在实现帧动画时,首先在Drawable下创建一个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/record_animate_01" android:duration="200" />    <item android:drawable="@drawable/record_animate_02" android:duration="200" />    <item android:drawable="@drawable/record_animate_03" android:duration="200" />    <item android:drawable="@drawable/record_animate_04" android:duration="200" />    <item android:drawable="@drawable/record_animate_05" android:duration="200" />    <item android:drawable="@drawable/record_animate_06" android:duration="200" />    <item android:drawable="@drawable/record_animate_07" android:duration="200" />    <item android:drawable="@drawable/record_animate_08" android:duration="200" />    <item android:drawable="@drawable/record_animate_09" android:duration="200" />    <item android:drawable="@drawable/record_animate_10" android:duration="200" />    <item android:drawable="@drawable/record_animate_11" android:duration="200" />    <item android:drawable="@drawable/record_animate_12" android:duration="200" />    <item android:drawable="@drawable/record_animate_13" android:duration="200" />    <item android:drawable="@drawable/record_animate_14" android:duration="200" /></animation-list>

每个item都是一张图片,duration用于设定改图片展示的时间,然后在代码中作为背景进行播放

<span style="font-size:14px;">iv = (ImageView) findViewById(R.id.iv_drawable);btn = (Button) findViewById(R.id.btn);iv.setBackgroundResource(R.drawable.drawable_animation);drawable = (AnimationDrawable) iv.getBackground();btn.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {drawable.start();}});</span>


这里找的是几个录制声音的图片,简单的连起来就是一个录制声音的图像



0 0