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

* 在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. miaov- 自动生成正V反V大于号V小于号V楼梯等图案

    1. 核心:控制 数量的长度-1-i的位置,是放在left上还是top上?是放在前面还是后面! <!DOCTYPE html> <html lang="en"&g ...

  2. css中的zoom的使用

    css中的zoom的使用  zoom : normal | number  normal : 默认值.使用对象的实际尺寸  number : 百分数 | 无符号浮点实数.浮点实数值为1.0或百分数为1 ...

  3. SQL-用JOIN连接多个表

    select * from table1 inner join table2 on table1.id=table2.id     其实 INNER JOIN --ON的语法格式可以概括为:      ...

  4. LeetCode Closest Binary Search Tree Value II

    原题链接在这里:https://leetcode.com/problems/closest-binary-search-tree-value-ii/ 题目: Given a non-empty bin ...

  5. eigen主页

    http://eigen.tuxfamily.org/index.php?title=Main_Page

  6. 8月17日 Power-BI关于全国房地产开发投资情况分析 QQ群视频交流开课啦

    <ignore_js_op> 数读|中国的经济只剩下房地产了么? 引言: 近日一则标题为“房奴们又立功啦,7月份新增贷款几乎都来自房贷!”的报道吸引了大众的目光.该报道指出在央行8月13日 ...

  7. 一些Demo链接

    youtube下载神器:https://github.com/rg3/youtube-dl我擦咧vim插件:https://github.com/Valloric/YouCompleteMevim插件 ...

  8. ios_图片放大的两种方式transform和frame

    frame改变x值y值的方式放大图片,是从左上开始放大. frame改变控件宽高的方式放大图片,是从中心开始放大. 原头像大小 用frame改变宽高 transform方式放大图片,从中心开始放大

  9. SHA-2 Certificate Signing Request

    To request an SSL certificate is now a SHA-2 Certificate Signing Request (CSR) is required. Using th ...

  10. docker note from UC blog

    -------------------------------------------------------------------------- original url http://tech. ...