且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Animation 作为ImageView的背景

更新时间:2022-09-22 09:57:37





  1. 声明一个Animation

<!-- 定义动画循环播放 -->

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

android:oneshot="false">

<item android:drawable="@drawable/butterfly_f01" android:duration="120" />

<item android:drawable="@drawable/butterfly_f02" android:duration="120" />

<item android:drawable="@drawable/butterfly_f03" android:duration="120" />

<item android:drawable="@drawable/butterfly_f04" android:duration="120" />

<item android:drawable="@drawable/butterfly_f05" android:duration="120" />

<item android:drawable="@drawable/butterfly_f06" android:duration="120" /> </animation-list>

2.布局文件

<ImageView

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:background="@anim/butterfly" />

3.开启动画

AnimationDrawable animDrawable = imageView.getBackgound();

animDrawable.start();
















本文转自wauoen51CTO博客,原文链接:http://blog.51cto.com/7183397/1567596 ,如需转载请自行联系原作者