android 学习随笔二十四(动画:帧动画)
- 帧动画,一张张图片不断的切换,形成动画效果
* 在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 学习随笔二十四(动画:帧动画)的更多相关文章
- android 学习随笔二十二(小结)
ADB进程 * adb指令 * adb install xxx.apk * adb uninstall 包名 * adb devices * adb start-server * adb kill-s ...
- android 学习随笔二十六(动画:属性动画)
属性动画,属性动画是真正改变对象的某个属性的值 * 补间动画,只是一个动画效果,组件其实还在原来的位置上,xy没有改变1.位移:* 第一个参数target指定要显示动画的组件* 第二个参数proper ...
- android 学习随笔二十五(动画:补间动画)
补间动画(TweenAnimation) * 原形态变成新形态时为了过渡变形过程,生成的动画就叫补间动画(为了让对象从初始状态向结束状态改变的过程更加自然而自动生成的动画效果)* 位移.旋转.缩放.透 ...
- android 学习随笔二十(多媒体编程 )
1.图片处理 加载大图片 图片大小的计算 图片大小 = 图片的总像素 * 每个像素占用的大小 * 单色图:每个像素占用1/8个字节* 16色图:每个像素占用1/2个字节* 256色图:每个像素占用1个 ...
- android 学习随笔二十九(自定义监听 )
package com.itheima.momo.dialog; import com.itheima.momo.R; import android.app.AlertDialog; import a ...
- android 学习随笔二十八(应用小知识点小结 )
去掉标题栏的方法 第一种:也一般入门的时候经常使用的一种方法requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏注意这句一定要写在setConte ...
- python3.4学习笔记(二十四) Python pycharm window安装redis MySQL-python相关方法
python3.4学习笔记(二十四) Python pycharm window安装redis MySQL-python相关方法window安装redis,下载Redis的压缩包https://git ...
- 学习笔记:CentOS7学习之二十四:expect-正则表达式-sed-cut的使用
目录 学习笔记:CentOS7学习之二十四:expect-正则表达式-sed-cut的使用 24.1 expect实现无交互登录 24.1.1 安装和使用expect 24.2 正则表达式的使用 24 ...
- 设计模式学习(二十四):Spring 中使用到的设计模式
设计模式学习(二十四):Spring 中使用到的设计模式 作者:Grey 原文地址: 博客园:设计模式学习(二十四):Spring 中使用到的设计模式 CSDN:设计模式学习(二十四):Spring ...
随机推荐
- web系统权限设计
应该有七张表 1.appSystem 表: 主要在多系统中的 统一权限管理:主要就是系统的URL USE [Star_Permission] GO /****** 对象: Table [dbo].[A ...
- [收藏夹整理]OpenCV部分
OpenCV中文论坛 OpenCV论坛 opencv视频教程目录(初级) OpenCV 教程 Opencv感想和一些分享 tornadomeet 超牛的大神 [数字图像处理]C++读取.旋转和保存bm ...
- 在定位中,如何清除已经设置好的bottom
这个东西其实很简单,将bottom设auto,便可在设置top的值,那么具体的应用是什么?目前一个是用于全屏,二是用于输入框在手机端的下半屏(被输入发遮挡问题)? 例子如下 css代码: * { ma ...
- preg_match_all
<meta charset="utf8"> <?php set_time_limit (0); for($i=1;$i<34;$i++){ $url = & ...
- Android适配(屏幕适配、国际化适配)-转
首先来说一下Android的屏幕适配: 关于Android屏幕的一些基本概念知识,自行充电..在此只介绍实际开发过程中的使用 1.说到Android的屏幕适配,首当其冲的就是图片的适配 图片适配遵循两 ...
- 文件传输基础——Java IO流
一.文件的编码 package com.study.io; /** * 测试文件编码 */ public class EncodeDemo { /** * @param args * @throws ...
- Java 收集的代码 transient
public class Main { public static void main(String[] args) { ((NULL)null).haha(); } } class NULL { p ...
- RouterOS 软路由开启SSH服务器
RouterOS软路由可以支持多种服务,例如SSH.FTP.Telnet.www等等 图形介面操作 命令操作 [admin@MikroTik] > ip service print ...
- linux 挂载命令详解
挂载文件系统与卸载文件系统 mount / umount NO1. 挂载光驱 [root@rehat root]# mount -t iso9660 /dev/cdrom /mnt/cdrom NO2 ...
- shapely and geos break在distance方法
问题 from shapely.geometry import Point print Point(0,0).distance(Point(1,1)) 报错 python: GeometryCompo ...