逐帧动画(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 ...
随机推荐
- jqGrid的选中行事件
http://blog.csdn.net/u014381863/article/details/50375121
- 一次疏忽导致的bug
NBB_PUT_SHORT 这个宏是按char* 类型算指针的实际工作中,没有注意这一点,输入指针类型 强转为了 SHORT* 导致 填充的内容错误 这是第一次在工作中遇到 指针类型相关的问题值得记录 ...
- 搜索引擎系列 ---lucene简介 创建索引和搜索初步
一.什么是Lucene? Lucene最初是由Doug Cutting开发的,2000年3月,发布第一个版本,是一个全文检索引擎的架构,提供了完整的查询引擎和索引引擎 :Lucene得名于Doug妻子 ...
- 【转】Oracle Database PSU/CPU
转自: http://www.cnblogs.com/ebs-blog/archive/2011/07/28/2167232.html 1. 什么是PSU/CPU?CPU: Critical Patc ...
- 压缩文本、字节或者文件的压缩辅助类-GZipHelper
下面为大家介绍一.NET下辅助公共类GZipHelper,该工具类主要作用是对文本.字符.文件等进行压缩与解压.该类主要使用命名空间:System.IO.Compression下的GZipStream ...
- sublime插件 TortioseSVN
TortioseSVN 可以安装在sublime中,实现svn文件的增加.删除.更新.提交等功能(TortioseSVN用在window系统中,linux安装svn) 安装: 首先在sublime中搜 ...
- AngularJs自定义指令详解(5) - link
在指令中操作DOM,我们需要link参数,这参数要求声明一个函数,称之为链接函数. 写法: link: function(scope, element, attrs) { // 在这里操作DOM} 如 ...
- 使用 hexdump dump 文件内容
名词解释 [dump] dump 是指把文件的内容,每个字节用2位十六进制数来表示的方式. 缘由 最近看矢泽久雄的<How Program Works>,了解到 dump “exe文件”( ...
- 3dmax渲染插件,生成2.5d瓦片
基于3dmax2013的2.5d渲染插件,demo版,需要的和感兴趣的可以试用,这是百度网盘地址:http://pan.baidu.com/s/1c0mYY7e 插件主要功能,按层级对3dmax场景进 ...
- 时间“Thu Aug 14 2014 14:28:06 GMT+0800”的转换
var date = "Thu Aug 14 2014 14:28:06 GMT+0800"; var va = DateTime.ParseExact(date, "d ...