• 帧动画,一张张图片不断的切换,形成动画效果

* 在drawable目录下定义xml文件,子节点为animation-list,在这里定义要显示的图片和每张图片的显示时长

* FrameAnimation
* 多张图片快速切换,形成动画效果
* drawable文件夹不放图片,只放资源文件
* ImageView显示图片可以设置内容(src),也可以设置背景(background)

<?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/g1" android:duration="200" />
<item android:drawable="@drawable/g2" android:duration="200" />
<item android:drawable="@drawable/g3" android:duration="200" />
<item android:drawable="@drawable/g4" android:duration="200" />
<item android:drawable="@drawable/g5" android:duration="200" />
<item android:drawable="@drawable/g6" android:duration="300" />
<item android:drawable="@drawable/g7" android:duration="300" />
<item android:drawable="@drawable/g8" android:duration="300" />
<item android:drawable="@drawable/g9" android:duration="200" />
<item android:drawable="@drawable/g10" android:duration="200" />
<item android:drawable="@drawable/g11" android:duration="200" />
</animation-list>

plusstolensee

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

<item android:drawable="@drawable/g1" android:duration="200" />
<item android:drawable="@drawable/g2" android:duration="200" />
<item android:drawable="@drawable/g3" android:duration="200" />
</animation-list>
* 在屏幕上播放帧动画

ImageView iv = (ImageView) findViewById(R.id.iv);
//把动画文件设置为imageView的背景
iv.setBackgroundResource(R.drawable.animations);
AnimationDrawable ad = (AnimationDrawable) iv.getBackground();
//播放动画
ad.start();

package com.itheima.frameanimation;

import android.os.Bundle;
import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.view.Menu;
import android.widget.ImageView; public class MainActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); ImageView rocketImage = (ImageView) findViewById(R.id.iv);
//设置iv的背景图
rocketImage.setBackgroundResource(R.drawable.plusstolensee);
//获取iv的背景
AnimationDrawable rocketAnimation = (AnimationDrawable) rocketImage.getBackground();
//开始播放
rocketAnimation.start();
} }

MainActivity

<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" > <ImageView
android:id="@+id/iv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
/> </RelativeLayout>

activity_main

android 学习随笔二十四(动画:帧动画)的更多相关文章

  1. android 学习随笔二十二(小结)

    ADB进程 * adb指令 * adb install xxx.apk * adb uninstall 包名 * adb devices * adb start-server * adb kill-s ...

  2. android 学习随笔二十六(动画:属性动画)

    属性动画,属性动画是真正改变对象的某个属性的值 * 补间动画,只是一个动画效果,组件其实还在原来的位置上,xy没有改变1.位移:* 第一个参数target指定要显示动画的组件* 第二个参数proper ...

  3. android 学习随笔二十五(动画:补间动画)

    补间动画(TweenAnimation) * 原形态变成新形态时为了过渡变形过程,生成的动画就叫补间动画(为了让对象从初始状态向结束状态改变的过程更加自然而自动生成的动画效果)* 位移.旋转.缩放.透 ...

  4. android 学习随笔二十(多媒体编程 )

    1.图片处理 加载大图片 图片大小的计算 图片大小 = 图片的总像素 * 每个像素占用的大小 * 单色图:每个像素占用1/8个字节* 16色图:每个像素占用1/2个字节* 256色图:每个像素占用1个 ...

  5. android 学习随笔二十九(自定义监听 )

    package com.itheima.momo.dialog; import com.itheima.momo.R; import android.app.AlertDialog; import a ...

  6. android 学习随笔二十八(应用小知识点小结 )

    去掉标题栏的方法 第一种:也一般入门的时候经常使用的一种方法requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏注意这句一定要写在setConte ...

  7. python3.4学习笔记(二十四) Python pycharm window安装redis MySQL-python相关方法

    python3.4学习笔记(二十四) Python pycharm window安装redis MySQL-python相关方法window安装redis,下载Redis的压缩包https://git ...

  8. 学习笔记:CentOS7学习之二十四:expect-正则表达式-sed-cut的使用

    目录 学习笔记:CentOS7学习之二十四:expect-正则表达式-sed-cut的使用 24.1 expect实现无交互登录 24.1.1 安装和使用expect 24.2 正则表达式的使用 24 ...

  9. 设计模式学习(二十四):Spring 中使用到的设计模式

    设计模式学习(二十四):Spring 中使用到的设计模式 作者:Grey 原文地址: 博客园:设计模式学习(二十四):Spring 中使用到的设计模式 CSDN:设计模式学习(二十四):Spring ...

随机推荐

  1. imx6 mac地址设置

    imx6的mac地址总是固定的值,所以需要更改,采用的方法是在uboot中设置环境变量,之后在kernel中使用uboot中设置的mac地址的值.本文记录更改的过程. 参考链接: http://www ...

  2. 人脸pts文件检查及人脸框输出

    function output() outtxt = fopen('D:\AR database\kz.txt','wt'); : imgpath= strcat('D:\AR database\kz ...

  3. 好网站:字体转换器在线转换 http://www.diyiziti.com/

    偶然间发现这个网站,它可以将文字设置字体并做成图片,也有很多好的字体下载如瘦金体. 下载下来的ttf文件在win7里可以右键点击install,在vista和xp里可以直接拷贝到window\font ...

  4. IDEA UML类图插件

    idea已经集成了该功能,只是默认没打开,仍然打开Settings界面,定位到Plugins,输入UML,参考下图:

  5. iOS7跳转AppStore地址

    跳转AppStore地址改变: 由 itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews? ...

  6. LeetCode Majority Element I && II

    原题链接在这里:Majority Element I,Majority Element II 对于Majority Element I 来说,有多重解法. Method 1:最容易想到的就是用Hash ...

  7. 移动端省际联动插件mobiscroll

    <link href="assets/css/mobiscroll.custom-2.17.0.min.css" rel="stylesheet" typ ...

  8. SQLServer temporary table and table variable

    Temporary tables are created in tempdb.  The name "temporary" is slightly misleading, for ...

  9. mysql 快速生成百万条测试数据

    1.生成思路 利用mysql内存表插入速度快的特点,先利用函数和存储过程在内存表中生成数据,然后再从内存表插入普通表中 2.创建内存表及普通表 CREATE TABLE `vote_record_me ...

  10. ASP.NET MVC Template

    http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-1-introduction.html http://st ...