<?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/nv1" android:duration="500" /><item android:drawable="@drawable/nv2" android:duration="500" /><item android:drawable="@drawable/nv3" android:duration="500" /><item android:drawable="@drawable/nv4" android:duration="500" />
</animation-list>

首先是建在res的drawable目录下面建一个 anmi_nv.xml文件,再写上上面的配置。

下面是MainActivity:

package mars.animations05;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;public class MainActivity extends Activity {private Button button = null;private ImageView imageView = null;@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);imageView = (ImageView)findViewById(R.id.imageViewId);button = (Button)findViewById(R.id.buttonId);button.setOnClickListener(new ButtonListener());}private class ButtonListener implements OnClickListener{public void onClick(View v) {imageView.setBackgroundResource(R.drawable.anim_nv);AnimationDrawable animationDrawable = (AnimationDrawable)imageView.getBackground();animationDrawable.start();}}
}

main.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical" android:layout_width="fill_parent"android:layout_height="fill_parent"><Button android:id="@+id/buttonId" android:layout_width="fill_parent"android:layout_height="wrap_content" android:layout_alignParentBottom="true"android:text="测试动画效果" /><LinearLayout android:orientation="vertical"android:layout_width="fill_parent" android:layout_height="fill_parent"><ImageView android:id="@+id/imageViewId"android:layout_width="wrap_content" android:layout_height="wrap_content"android:layout_centerInParent="true" android:layout_marginTop="100dip"/></LinearLayout>
</RelativeLayout>

mars老师的视频,第二季。

Frame-By-Frame Animations的使用方法相关推荐

  1. python表单切换_python3 selenium自动化 frame表单嵌套的切换方法

    在web自动化测试中,测试工程师经常会碰到frame表单嵌套结构,直接定位会报错,我们需要切换表单后才能成功定位. 我拿QQ邮箱登录来作为例子说下frame怎么切换. qq邮箱页面按F12可以看到以下 ...

  2. Animations的使用方法

    Animations的使用方法 使用Animations的步骤: 1.创建一个AnimationSet对象(Animation子类): 2.增加需要创建相应的Animation对象: 3.更加项目的需 ...

  3. html取代frame框架,替代iframe的最好方法 什么东西可以替代iframe

    现在有什么好的办法取代 iframe 我以前就用过AJAX做过管理页面,左侧菜单不用每次都重新加载,你让他每次点击左侧链接或按钮然后调用AJAX加载右侧的内容就行 什么东西可以替代iframe HTM ...

  4. frame 和 frame属性

    帧标志 1.<frameset></frameset> 2.<frame> 3.<noframes></noframes> 帧是由英文Fra ...

  5. 在html语言中frame,html Frame、Iframe、Frameset 的区别

    10.4.1  Frameset与Frame的区别 首先讲解Frameset与Frame之间的区别. 用来划分框架,每一个框架由标记.必须在之内使用,代码如下: 在上面的例子当中, 把页面分为左右两个 ...

  6. python中frame用法_Python实例之wxpython中Frame使用方法

    本节为大家分享的例子是wxpython Frame的用法. 例子: 代码如下: #!/usr/bin/python # -*- coding: GBK -*- # simple.py import w ...

  7. 修改frame快捷方法,不必再繁琐的计算

    平时计算控件frame时我们是这样计算的: //首先设置frame view.frame = CGRectMake(0, 0, 320, 150); //如果想改变其中的宽或者高或者位置,则需要重新设 ...

  8. python中frame是什么意思_Python实例之wxpython中Frame使用方法

    本节为大家分享的例子是wxpython Frame的用法. 例子: #!/usr/bin/python # -*- coding: GBK -*- # simple.py import wx app ...

  9. frameset和frame的使用方法

    <frameset>  <frame src="url">  <frame src="url">  ...  </fr ...

最新文章

  1. Spring基础专题——第二章(注入Injection)
  2. mysql 日志管理
  3. X-Shell远程连接虚拟机
  4. SpringCloud--Eureka服务注册与发现 Eureka 集群搭建 详细案例!!!
  5. 团队冲刺the second day
  6. Hive的索引操作【小结】
  7. 搜索---广度优先遍历、深度优先遍历、回溯法
  8. Linux C 预处理详解
  9. 【转】nginx+iis实现负载均衡
  10. 从0到上线一个完整Java项目,需要具备哪些技能?
  11. Excel常用公式之LOOKUP
  12. 【工具篇】AS连接不上夜神模拟器
  13. openlayers中海图的加载
  14. idea彩虹括号+区域代码高亮插件
  15. 『UE4数字孪生』开发流程浅析2022版(持续更新)
  16. 慕思618静悄悄,暴利生意做不下去了?
  17. 个人怎么申请微信公众号
  18. Bootstrap Switch 开关控件
  19. Packet len* is out of range 解决方法
  20. python基础-PyYaml操作yaml文件

热门文章

  1. 串口一拖二——硬件实现、软件使用
  2. fancybox参数设置
  3. SEO站群外链建设批量管理
  4. Codeforces Round #413 C. Fountains (线段树的创建、查询、更新)
  5. 常用的RFID卡 14443A/B, 15693
  6. 【Web技术】772- Web 中文字体性能优化实践
  7. Jenkins 自动化测试部署流程
  8. 通达oa服务器文件夹管理,通达OA目录层次结构
  9. PB powerbuilder timing类
  10. B2B电商的几大核心问题