在Android的动画中有一种叫做Frame by Frame 的动画效果,就是跟Flash播放一样,是一帧一帧地显示,如果动画是连续并且有规律的话,就跟播放视频一样。

首先在drawable目录下添加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/psb1"
android:duration="500"/>
<item android:drawable="@drawable/psb2"
android:duration="500"/>
<item android:drawable="@drawable/psb3"
android:duration="500"/>
<item android:drawable="@drawable/psb4"
android:duration="500"/> </animation-list>

布局文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" /> <Button
android:id="@+id/alpha"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="动画效果演示"/> <ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="50dip"/> </LinearLayout>

在Activity中

package com.example.animation;

import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView; import com.example.widgetdemo.R; public class AnimationXmlDemo3 extends Activity {
private Button alpha = null;
private ImageView image = null; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.animation_xml3);
alpha = (Button) findViewById(R.id.alpha);
image = (ImageView) findViewById(R.id.image); alpha.setOnClickListener(new alphaListener());
} class alphaListener implements OnClickListener { @Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
//为图片添加图片背景
image.setBackgroundResource(R.drawable.anim_nv);
AnimationDrawable animationDrawable = (AnimationDrawable) image
.getBackground();
animationDrawable.start();
} }
}

这样一个连续显示图片的效果就完成了。

源码下载:

点击打开链接

Android常用动画Frame-By-Frame Animations的使用的更多相关文章

  1. Android 常用动画

    一.动画类型 Android的animation由四种类型组成:alpha.scale.translate.rotate XML配置文件中 alpha :渐变透明度动画效果 scale :渐变尺寸伸缩 ...

  2. Android 常用动画之RotateAnimation

    前两天接到任务做一个UI,有用到动画,于是抽空看了下Android动画相关知识. Android Animation共有四大类型,分别是 Alpha      透明度动画 Scale      大小伸 ...

  3. Android常用动画alpha和rotate同时使用

    Android的动画可以是一种动画,也可以多种动画作用于一张图片上,如RotaeAnimation和AlphaAnimation同时放到一个配置文件中 alpha1.xml <?xml vers ...

  4. Android Animation 动画Demo(Frame帧动画)

    上一页介绍Animation动画第一:Tween吐温动画. 本文介绍了以下Animation也有动画的形式:Frame帧动画. Frame动画是一系列照片示出的顺序按照一定的处理,和机制,以放电影很阶 ...

  5. Android常用动画Animation的使用

    Andriod中有几种常用的Animation AlphaAnimation  淡入淡出效果 RotateAnimation 旋转效果 ScaleAnimation 缩放动画 TranslaAnima ...

  6. Android 常用动画小结

    1. 渐入动画 // Request the next activity transition (here starting a new one). startActivity(new Intent( ...

  7. Android动画效果之Frame Animation(逐帧动画)

    前言: 上一篇介绍了Android的Tween Animation(补间动画) Android动画效果之Tween Animation(补间动画),今天来总结下Android的另外一种动画Frame ...

  8. Android 动画具体解释Frame动画 (Drawable Animation)

    Frame动画像gif画画,通过一些静态的图片,以实现动画效果. Android sdk该AnimationDrawable就是专门针对Frame动画,当然Frame动画也可在java代码或者xml中 ...

  9. Android 属性动画 源码解析 深入了解其内部实现

    转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/42056859,本文出自:[张鸿洋的博客] 我参加了博客之星评选,如果你喜欢我的博 ...

随机推荐

  1. 在SQL2005中部署CLR 程序集

    原文 在SQL2005中部署CLR 程序集 有关于CLR函数的用途和用法,请了解 SQL Server CLR 极速入门,启用.设计.部署.运行 http://www.yongfa365.com/It ...

  2. Oracle 表三种连接方式(sql优化)

    在查看sql执行计划时,我们会发现表的连接方式有多种,本文对表的连接方式进行介绍以便更好看懂执行计划和理解sql执行原理. 一.连接方式: 嵌套循环(Nested Loops (NL)) (散列)哈希 ...

  3. Connection for controluser as defined in your configuration failed.

    在mysql中使用事件调度器(计划任务), 语句写好了,运行也ok,可是却没有预期的结果.网上总结了非常多计划任务失效的原因.没有一种适合我. 在phpmyadmin中打开事件表,发现以下一串红色的提 ...

  4. Struts2 API的chm格式帮助文档制作教程

    Struts2 API的chm格式帮助文档制作教程 在SSH三个框架中,Struts2的API文档是最难做的,这里所说的格式是chm格式的,chm的格式很方便,Hibernate API文档和Spri ...

  5. openstack安装配置

    openstack:1.控制节点安装所有,计算节点只有nova-compute:2.网络选择: nova-network还是neutron: nova-network比较简单, neutron功能强大 ...

  6. css两列布局,一边固定宽度,另一边自适应

    <!DOCTYPE HTML><HTML>    <head>                <meta charset="utf-8" ...

  7. if语句之猜拳

    用计算机来生成随机数: Random rand = new Random();//做一个随机生成器,Random();后面的括号里面可以放一个随机生成器种子,这个种子只能为整数(int)int n = ...

  8. UVa----------1594(Ducci Sequence)

    题目: 1594 - Ducci Sequence Asia - Seoul - 2009/2010A Ducci sequence is a sequence of n-tuples of inte ...

  9. Oracle/Mysql批量插入的sql,效率比较高

    1.oracle 批量插入: insert into tableName(col1,col2,col3...)    select 1,'第一行第一列值','第二列值' from dual union ...

  10. oracle去除字符串中间的空格

    update AC01 A set A.AAC003 = REGEXP_REPLACE(A.AAC003, '( ){1,}', '') WHERE A.AAC002 IN (SELECT AAC00 ...