逐帧动画(Frame-by-frame Animations)
1.这一类动画可以创建一个Drawable序列,这些Drawable可以按照指定的时间间歇一个一个的显示.
xml定义方法
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="tu1" android:duration="200"/>
<item android:drawable="tu2" android:duration="200"/>
<item android:drawable="tu3" android:duration="200"/>
</animation-list>
2.逐帧动画是在drawable下创建的一种图片,根节点是animation-list(动画列表),oneshot属性表示是否只播放一次,内部用item节点声明一个个的动画。
其中drawable指明使用的图片,duration属性这一动画显示的时间,单位毫秒。
然后可以将其当做背景图片来使用
<TextView
android:id="@+id/main_tv"
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@drawable/animation_list"/>
3.然开在代码中开始播放动画即可
((AnimationDrawable)img.getBackground()).start();
//=============
实例:帧动画
效果图:

Demo1\app\src\main\res\drawable\anim_frame.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/aa"
android:duration="500" />
<item
android:drawable="@drawable/bb"
android:duration="500" />
<item
android:drawable="@drawable/cc"
android:duration="500" />
<item
android:drawable="@drawable/dd"
android:duration="500" />
<item
android:drawable="@drawable/ee"
android:duration="500" />
<item
android:drawable="@drawable/ff"
android:duration="500" />
</animation-list>
Demo1\app\src\main\res\layout\activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"> <ImageView
android:id="@+id/main_img"
android:layout_width="100dp"
android:layout_height="180dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@drawable/anim_frame"/>
</RelativeLayout>
Demo1\app\src\main\java\com\ly\demo1\MainActivity.java
package com.ly.demo1; import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.widget.ImageView; public class MainActivity extends Activity {
private ImageView img; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
img = (ImageView) findViewById(R.id.main_img);
((AnimationDrawable)img.getBackground()).start();
} }
逐帧动画(Frame-by-frame Animations)的更多相关文章
- Android动画效果之Frame Animation(逐帧动画)
前言: 上一篇介绍了Android的Tween Animation(补间动画) Android动画效果之Tween Animation(补间动画),今天来总结下Android的另外一种动画Frame ...
- Android简单逐帧动画Frame的实现(三)
android之动画(三)通过AnimationDrawable控制逐帧动画 android与逐帧动画: 效果图: 当我们点击按钮时,该图片会不停的旋转,当再次点击按钮时,会停止在当前的状态. ...
- Android简单逐帧动画Frame的实现(二)
Android简单逐帧动画Frame的实现 Android简单逐帧动画Frame的实现 1.逐帧动画 即是通过播放预先排序好的图片来实现动态的画面,感觉像是放电影. 2.实现步骤: 1. 在工程里 ...
- Android 学习之逐帧动画(Frame)
帧动画就是将一些列图片.依次播放. 利用肉眼的"视觉暂留"的原理,给用户的感觉是动画的错觉,逐帧动画的原理和早期的电影原理是一样的. a:须要定义逐帧动画,能够通过代码定义.也能够 ...
- Android 逐帧动画isRunning 一直返回true的问题
AnimationDrawabl主要通过xml实现逐帧动画,SDK实例如下: An AnimationDrawable defined in XML consists of a single < ...
- Android笔记(六十三) android中的动画——逐帧动画( frame-by-frame animation)
就好像演电影一样,播放实现准备好的图片,来实现动画效果. 逐帧动画需要用到AnimationDrawable类,该类主要用于创建一个逐帧动画,然后我们把这个动画设置为view的背景即可. androi ...
- Android 逐帧动画
原理: 逐帧动画是最简单的一种动画.原理就是把几张图片连续显示出来,以达到动画的效果.就相当于下面这种手绘翻页动画啦~ 实现: 1.需要建立一个animation-list来设置静态图片资源.持续时间 ...
- css3 实现逐帧动画
css3 实现逐帧动画 实现逐帧动画需要使用到的是Animation动画,该CSS3的Animation有八个属性:分别是如下:1: animation-name2: animation-durati ...
- Esfog_UnityShader教程_逐帧动画
有段日子没出这个系列的新文章了,今天就拿一个比较常见也比较基础的利用改变Shader来改变不断调整UV实现播放逐帧动画的小功能.很久没写了就当练练手了.在新版本的Unity中早就已经集成了Sprite ...
随机推荐
- php常用的字符串函数
addslashes -- 使用反斜线引用字符串 chr -- 返回相对应于 ascii 码值所指定的单个字符. chunk_split -- 将字符串分割成小块 count_chars -- 返回 ...
- EXCEL拼接SQL
=CONCATENATE("insert into 表名 (字段名1,字段名2)values (3, '"&C3&"');") 用CONCAT ...
- jQuery Mobile 表单输入元素
jQuery Mobile 文本输入 输入字段是通过标准的 HTML 元素编写的,jQuery Mobile 会为它们设置专门针对移动设备的美观易用的样式.您还可以使用新的 HTML5 <inp ...
- [转] Oracle sql 查询突然变慢 -- 案例分析
转自:http://jingyan.baidu.com/article/8275fc868ce57946a03cf692.html 一条sql突然执行变慢,耗时9秒,应用是不能改的,只能从数据库方面下 ...
- C# SHA1散列算法
C# SHA1散列算法 /// <summary> /// C# SHA1散列算法 /// </summary> /// <param name="str&qu ...
- SQLServer idenity 字段跳值
修改数据库实例的启动参数 然后修改SQLServer启动参数,打开SQLServer configuration manager,然后选择服务实例,点击右键属性,查看实例的属性界面,然后启动参数选项输 ...
- ng animate
要在angular中加入动画必须引入angular.animate.js插件,然后就可以在module中引入ngAnimate模块.如: var module1 = angular.module('m ...
- vertx简单客户端创建
import java.util.HashMap;import java.util.Map; import com.yunva.vertx.test.vertproject.util.JsonUtil ...
- MongoDB GridFS 对图片进行增删改
using MongoDB.Bson; using MongoDB.Driver; using MongoDB.Driver.Builders; using MongoDB.Driver.GridFS ...
- 19. UIAlertController 提示框获取文本内容,打印控制台上
1.首先定义一个全局字符串变量,方便接收获取的文本内容 2. -(void)viewDidAppear:(BOOL)animated{ UIAlertController * alert = [UIA ...