http://stackoverflow.com/questions/10909865/setanimation-vs-startanimation-in-android

http://blog.csdn.net/wyhuan1030/article/details/7409869

设置一个动画播放这一观点。如果你想立即播放的动画,使用startAnimation这种方法提供了允许细粒度控制的起始时间和失效,

但你必须确保:1)动画开始时间 2)动画应该开始时的观点,将被视为无效。

  1. <span id="result_box" lang="zh-CN"></span>
  2. /**
  3. * Sets the next animation to play for this view.
  4. * If you want the animation to play immediately, use
  5. * startAnimation. This method provides allows fine-grained
  6. * control over the start time and invalidation, but you
  7. * must make sure that 1) the animation has a start time set, and
  8. * 2) the view will be invalidated when the animation is supposed to
  9. * start.
  10. *
  11. * @param animation The next animation, or null.
  12. */
  13. public void setAnimation(Animation animation) {
  14. mCurrentAnimation = animation;
  15. if (animation != null) {
  16. animation.reset();
  17. }
  18. }

现在开始指定的动画。

  1. /**
  2. * Start the specified animation now.
  3. *
  4. * @param animation the animation to start now
  5. */
  6. public void startAnimation(Animation animation) {
  7. animation.setStartTime(Animation.START_ON_FIRST_FRAME);
  8. setAnimation(animation);
  9. invalidateParentCaches();
  10. invalidate(true);
  11. }

建议使用

startAnimation来启动动画,setAnimation启动动画是需要条件的

【转】setAnimation和startAnimation区别的更多相关文章

  1. Android中res下anim和animator文件夹区别与总结

    1.anim文件夹 anim文件夹下存放tween animation(补间动画)和frame animation(逐帧动画) 逐帧动画: ①在animation-list中使用item定义动画的全部 ...

  2. c#与java的区别

    经常有人问这种问题,用了些时间java之后,发现这俩玩意除了一小部分壳子长的还有能稍微凑合上,基本上没什么相似之处,可以说也就是马甲层面上的相似吧,还是比较短的马甲... 一般C#多用于业务系统的开发 ...

  3. jquery和Js的区别和基础操作

    jqery的语法和js的语法一样,算是把js升级了一下,这两种语法可以一起使用,只不过是用jqery更加方便 一个页面想要使用jqery的话,先要引入一下jqery包,jqery包从网上下一个就可以, ...

  4. 【原】nodejs全局安装和本地安装的区别

    来微信支付有2年多了,从2年前的互联网模式转变为O2O模式,主要的场景是跟线下的商户去打交道,不像以往的互联网模式,有产品经理提需求,我们帮忙去解决问题. 转型后是这样的,团队成员更多需要去寻找业务的 ...

  5. 探究@property申明对象属性时copy与strong的区别

    一.问题来源 一直没有搞清楚NSString.NSArray.NSDictionary--属性描述关键字copy和strong的区别,看别人的项目中属性定义有的用copy,有的用strong.自己在开 ...

  6. X86和X86_64和X64有什么区别?

    x86是指intel的开发的一种32位指令集,从386开始时代开始的,一直沿用至今,是一种cisc指令集,所有intel早期的cpu,amd早期的cpu都支持这种指令集,ntel官方文档里面称为&qu ...

  7. Java中Comparable与Comparator的区别

    相同 Comparable和Comparator都是用来实现对象的比较.排序 要想对象比较.排序,都需要实现Comparable或Comparator接口 Comparable和Comparator都 ...

  8. MySQL中interactive_timeout和wait_timeout的区别

    在用mysql客户端对数据库进行操作时,打开终端窗口,如果一段时间没有操作,再次操作时,常常会报如下错误: ERROR (HY000): Lost connection to MySQL server ...

  9. 设置line-height:1.5和line-height:150%或者line-height:150px的区别

    直接正题: 看一下line-height可能的值: 其实可以分为两类: (1)不带单位的(如line-height:1.5),这种是推荐使用的: (2)带单位的(如line-heigth:30px/1 ...

随机推荐

  1. javascript 获取 class 样式 重新赋值class样式 为div等系列标签内更改内容

    name = document.getElementById(project_not_through_id).className;                     // 获取目标id的 cla ...

  2. apache2.4配置虚拟目录

    刚开始学习,跟着韩顺平老师的视频课件学习ing~ 这是自己在配置虚拟目录时遇到的问题以及解决办法,记录下来~ ---------------------------分割线君-------------- ...

  3. php 常用

    零:重要的PHP超级全局变量 1.$_SERVER $_SERVER超级全局变量包含由web服务器创建的信息,它提供了服务器和客户配置及当前请求环境的有关信息.根据服务器不同,$_SERVER中的变量 ...

  4. WPF Window对象

    户通过窗口与 Windows Presentation Foundation (WPF) 独立应用程序进行交互.窗口的主要用途是承载可视化数据并使用户可以与数据进行交互的内容.独立 WPF 应用程序使 ...

  5. Android Audio 分析

    一.架构 二.MediaServer初始化 所有的media服务都在进程mediaserver里.其代码在framework/base/media/mediaserver/main_mediaserv ...

  6. deep learning framework(不同的深度学习框架)

    常用的deep learning frameworks 基本转自:http://www.codeceo.com/article/10-open-source-framework.html 1. Caf ...

  7. Shoot the Bullet

    zoj3229:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3442 题意:一个摄影师,在n天内给m个女神拍照.每个女神至少要 ...

  8. C/C++ 开源库及示例代码

    C/C++ 开源库及示例代码 Table of Contents 说明 1 综合性的库 2 数据结构 & 算法 2.1 容器 2.1.1 标准容器 2.1.2 Lockfree 的容器 2.1 ...

  9. Android开源项目发现---Spinner选择器与日历选择器篇(持续更新)

    1. android-times-square Android日历部件 支持选取单个日期,多个日期,及日期区间段和对话框形式显示 项目地址:https://github.com/square/andr ...

  10. Git创建一个自己的本地仓库

    如果我们要把一个项目加入到Git的版本管理中,可以在项目所在的目录用git init命令建立一个空的本地仓库,然后再用git add命令把它们都加入到Git本地仓库的暂存区(stage or inde ...