Android uses animation list to realize frame animation

This example shares the specific code of using animation list to realize frame animation for your reference. The specific contents are as follows

Put the pictures to be played in sequence in the resource directory

Create new animation1 and animation2 files in the drawable directory. One is to display the animation in order and the other is to display the animation in reverse order,

Sequentially display the animation file: animation1.xml

<?xml version="1.0" encoding="utf-8"?> 
<!--  
  根标签为animation-list,其中oneshot代表着是否只展示一遍,设置为false会不停的循环播放动画 
  根标签下,通过item标签对动画中的每一个图片进行声明 
  android:duration 表示展示所用的该图片时间长度 
 --> 
<animation-list 
 xmlns:android="http://schemas.android.com/apk/res/android" 
 android:oneshot="true" 
 > 
  <item android:drawable="@drawable/icon1" android:duration="150"></item> 
  <item android:drawable="@drawable/icon2" android:duration="150"></item> 
  <item android:drawable="@drawable/icon3" android:duration="150"></item> 
  <item android:drawable="@drawable/icon4" android:duration="150"></item> 
  <item android:drawable="@drawable/icon5" android:duration="150"></item> 
  <item android:drawable="@drawable/icon6" android:duration="150"></item> 
</animation-list> 

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>