Animator 代表一个属性动画,但它只是一个抽象类,通常会使用它的子类:AnimatorSet、ValueAnimator、ObjectAnimator、TimeAnimator。
定义属性动画的 XML 资源文件能以如下三个元素中的任意一个作为根元素。
  • <set.../>:它是一个父元素,用于包含其他<objectAnimator.../>、<animator.../>或 <set.../>子元素,该元素定义的资源代表 AnimatorSet 对象。
  • <objectAnimator.../>:用于定义 ObjectAnimator 动画。
  • <animator.../>:用于定义 ValueAnimator 动画。
实例:不断渐变的背景色
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/container"
>
</LinearLayout>
color_anim.xml
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:propertyName="backgroundColor"
android:duration="3000"
android:valueFrom="#FF8080"
android:valueTo="#8080FF"
android:repeatCount="infinite"
android:repeatMode="reverse"
android:valueType="intType">
</objectAnimator>
AnimatorTest.java
package org.crazyit.res;

import android.animation.AnimatorInflater;
import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout; /**
* Description:
* <br/>site: <a href="http://www.crazyit.org">crazyit.org</a>
* <br/>Copyright (C), 2001-2014, Yeeku.H.Lee
* <br/>This program is protected by copyright laws.
* <br/>Program Name:
* <br/>Date:
* @author Yeeku.H.Lee kongyeeku@163.com
* @version 1.0
*/
public class AnimatorTest extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LinearLayout container = (LinearLayout)
findViewById(R.id.container);
// 添加MyAnimationView组件
container.addView(new MyAnimationView(this));
} public class MyAnimationView extends View
{
public MyAnimationView(Context context)
{
super(context);
// 加载动画资源
ObjectAnimator colorAnim = (ObjectAnimator) AnimatorInflater
.loadAnimator(AnimatorTest.this, R.animator.color_anim);
colorAnim.setEvaluator(new ArgbEvaluator());
// 对该View本身应用属性动画
colorAnim.setTarget(this);
// 开始指定动画
colorAnim.start();
}
}
}
 

属性动画(Property Animation)资源的更多相关文章

  1. Android动画主要包含补间动画(Tween)View Animation、帧动画(Frame)Drawable Animation、以及属性动画Property Animation

    程序运行效果图: Android动画主要包含补间动画(Tween)View Animation.帧动画(Frame)Drawable Animation.以及属性动画Property Animatio ...

  2. 使用属性动画 — Property Animation

    属性动画,就是通过控制对象中的属性值产生的动画.属性动画是目前最高级的2D动画系统. 在API Level 11中添加.Property Animation号称能控制一切对象的动画,包括可见的和不可见 ...

  3. 使用属性动画 — Property Animation

    属性动画,就是通过控制对象中的属性值产生的动画.属性动画是目前最高级的2D动画系统. 在API Level 11中添加.Property Animation号称能控制一切对象的动画,包括可见的和不可见 ...

  4. Android 动画——属性动画Property Animation

    Android在3.0之前只提供了两种动画:View Animation .Drawable Animation .也就是我们在<Android 动画——Frame Animation与Twee ...

  5. 属性动画(Property Animation)

    属性动画系统是一个强大的可以绘制任意事物.你可以定义改变物体属性的动画,不管它是不是在屏幕上.属性动画随着时间的推移去改变物体的属性.如果要让某个事物动起来,你只需指定该事物的某个属性,如物体的坐标. ...

  6. 属性动画Property Animation

    ViewPropertyAnimation 使用方式:View.animate() 后跟 translationX() 等方法,动画会自动执行. 注意translationX实现是调用对应的set方法 ...

  7. Android(java)学习笔记263:Android下的属性动画(Property Animation)

    1. 属性动画(Property Animation)引入: 在手机上去实现一些动画效果算是件比较炫酷的事情,因此Android系统在一开始的时候就给我们提供了两种实现动画效果的方式,逐帧动画(fra ...

  8. Android(java)学习笔记207:Android下的属性动画(Property Animation)

    1. 属性动画(Property Animation)引入: 在手机上去实现一些动画效果算是件比较炫酷的事情,因此Android系统在一开始的时候就给我们提供了两种实现动画效果的方式,逐帧动画(fra ...

  9. Android动画:模拟开关按钮点击打开动画(属性动画之平移动画)

    在Android里面,一些炫酷的动画确实是很吸引人的地方,让然看了就赏心悦目,一个好看的动画可能会提高用户对软件的使用率.另外说到动画,在Android里面支持3种动画: 逐帧动画(Frame Ani ...

  10. 【转】android 属性动画之 ObjectAnimator

    原文网址:http://blog.csdn.net/feiduclear_up/article/details/39255083 前面一篇博客讲解了 android 简单动画之 animtion,这里 ...

随机推荐

  1. [Unity-24] Unity的四种载入场景的方法

    Unity官方提供了4种载入场景(scene)的方法.各自是: 1. Application.LoadLevel():同步载入 2. Application.LoadLevelAsync():异步载入 ...

  2. linux常用命令 http://mirrors.163.com/ubuntu-releases/12.04/

    由于记忆力有限,把平时常用的Linux命令整理出来,以便随时查阅: linux 基本命令 ls     (list 显示当前目录下文件和目录 ls -l 详细显示 =ll ) [root@linux ...

  3. UIView不能使用UITableView的Static表格的解决方法

    在UIView中嵌入一个Container,用Container来包含UITableViewController即可,到storyboard上显示如下:

  4. Notice : Soft open files now is 1024, We recommend greater than 10000

    在研究 workerman 时, 报了这个错误, 感觉只是个notice级别的, 就一直给忽略掉了, 今天有时间, 就查了一下. 其实本质就是 ulimit 这个命令 打开一个命令行, 输入 ulim ...

  5. HDU 4455(dp)

    题意:给定一个序列ai,个数为n.再给出一系列w:对于每个w,求序列中,所有长度为w的连续子串中的权值和,子串权值为子串中不同数的个数. 思路:动态规划,用dp[w]表示当前长度为w的时候的权值和.显 ...

  6. noip 2012 疫情控制

    /* 考试的时候没想出正解 也没打暴力 时间不够了 随便yy了几种情况按出现的先后顺序处理而没有贪心 的了20分 不粘了 正解是围绕首都的儿子来搞的 显然先二分答案 对于每个限定的最大时间 我们尝试着 ...

  7. java.lang.ClassCastException

    是指类型转换出错 当前者的域小于后者的时候出现 譬如说:前者A是子类的对象,而后者B是父类的对象 若使用A = B;就会抛出java.lang.ClassCastException List<C ...

  8. 关于图表的JS插件

    http://echarts.baidu.com/ http://echarts.baidu.com/tutorial.html#5%20%E5%88%86%E9%92%9F%E4%B8%8A%E6% ...

  9. Swift - 32 - 函数类型

    //: Playground - noun: a place where people can play import UIKit func add(a:Int, b:Int) -> Int { ...

  10. javascript基础学习(十一)

    javascript之BOM 学习要点: BOM介绍 Window对象 一.BOM介绍 浏览器对象模型简称为BOM(Brower Object Model),BOM由很多对象构成,对象与对象之间有着相 ...