Android 实现gif动画效果1

来源:互联网 发布:cnn student news 软件 编辑:程序博客网 时间:2024/05/20 12:46

1.四张GIF图片和一个anim_nv.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/nv1" android:duration="500" />
<item android:drawable="@drawable/nv2" android:duration="500" />
<item android:drawable="@drawable/nv3" android:duration="500" />
<item android:drawable="@drawable/nv4" android:duration="500" />
</animation-list>

2.layout

<ImageView

         android:id="@+id/imageView3"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:src="@drawable/anim_nv"  />

3.main.activity

        ImageView  imageView3 = (ImageView) findViewById(R.id.imageView3);
imageView3.setBackgroundResource(R.drawable.anim_nv);
AnimationDrawable animationDrawable = (AnimationDrawable)imageView3.getBackground();
animationDrawable.start();

0 0
原创粉丝点击