Android Animations简介
一 、Animations简介
Animations提供了一系列的动画效果,这些效果可以应用于绝大多数的控件;
二、Animations的分类
第一类:TweenedAnimations,该类Animations提供了旋转,移动,淡入淡出和缩放等效果;
第二类:Frame-by-Frame Animations,这类Animations可以创建一个Drawable序列,这些Drawable可以按照指定的时间间歇一个个的显示;
TweenedAnimations介绍
(1)TweenedAnimations可以分为下面几类:
1. Alpha:淡入淡出效果
2. Scale:缩放效果
3. Rotate:旋转效果
4. Translate:移动效果
(2)Animations的使用方法:
一种是在Java代码中使用,另一种是定义在XML文件中;
(3)在Java代码中使用步骤为:
a) 创建一个AnimationSet对象;
b)根据需要创建相应的Animation对象;
c)根据软件动画的需求,为Animation对象设置相应的数据;
d)将Animation对象添加到AnimationSet对象当中;
e)使用控件对象开始执行AnimationSet;
而Animation在代码中对应的四个子类分别为:
AlphaAnimation、TranslateAnimation、ScaleAnimation、RotateAnimation
例子:

代码如下:
activity_main.xml
<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="com.xiaozhang.animationtest.MainActivity" >
<Button
android:id="@+id/scaleButtonId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="scale动画效果" />
<Button
android:id="@+id/rotateButtonId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/scaleButtonId"
android:text="rotate动画效果" />
<Button
android:id="@+id/alphaButtonId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/rotateButtonId"
android:text="alpha动画效果" />
<Button
android:id="@+id/translateButtonId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/alphaButtonId"
android:text="translate动画效果" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageViewId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:src="@drawable/icon" />
</LinearLayout>
</RelativeLayout>
MainActivity.java
package com.xiaozhang.animationtest;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;
public class MainActivity extends Activity {
private ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.imageViewId);
imageView = (ImageView) findViewById(R.id.imageViewId);
findViewById(R.id.rotateButtonId).setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
AnimationSet animationSet = new AnimationSet(true);
RotateAnimation rotateAnimation = new RotateAnimation(
0, 360, Animation.RELATIVE_TO_PARENT, 0.3f,
Animation.RELATIVE_TO_PARENT, 0.3f);
rotateAnimation.setDuration(1000);
animationSet.addAnimation(rotateAnimation);
imageView.startAnimation(animationSet);
}
});
findViewById(R.id.scaleButtonId).setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
AnimationSet animationSet = new AnimationSet(true);
ScaleAnimation scaleAnimation = new ScaleAnimation(1,
0.0f, 1, 0.0f, Animation.RELATIVE_TO_PARENT,
0.1f, Animation.RELATIVE_TO_PARENT, 0.1f);
scaleAnimation.setDuration(1000);
animationSet.addAnimation(scaleAnimation);
imageView.startAnimation(animationSet);
}
});
findViewById(R.id.alphaButtonId).setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
// 创建一个AnimationSet对象
AnimationSet animationSet = new AnimationSet(true);
// 创建一个AlphaAnimation对象
AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);
// 设置整个动画执行所需要的时间
alphaAnimation.setDuration(2000);
// 将AlphaAnimation对象添加到AnimationSet当中
animationSet.addAnimation(alphaAnimation);
// 使用控件执行动画效果
imageView.startAnimation(alphaAnimation);
}
});
findViewById(R.id.translateButtonId).setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
AnimationSet animationSet = new AnimationSet(true);
TranslateAnimation translateAnimation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0f,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0f,
Animation.RELATIVE_TO_SELF, 1.0f);
translateAnimation.setDuration(1000);
animationSet.addAnimation(translateAnimation);
imageView.startAnimation(translateAnimation);
}
});
}
}
另外,Animation或AnimationSet有一系列的方法,如:
setDuration(long) :设置动画持续时间(单位:毫秒)
setFillAfter(boolean) :如果参数为true,则动画执行结束后,控件将停留在结束的状态
setFillBefore(boolean) :如果参数为true,则动画执行结束后,控件将回到执行前的状态
setStartOffset(long) :设置动画执行前的等待时间
setRepeatCount(int) :设置动画重复执行的次数
(4)使用XML文件来执行Animation;
a)在res文件夹下新建一个名为anim的文件夹;
b)为各个不同的效果分别创建xml文件,并首先加入set标签,标签代码如下:
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator" >
</set>
c)在该标签中分别加入rotate,alpha,scale或translate标签;
d)在代码当中使用AnimationUtils装载xml文件,并生成Animation对象;
例子如上,代码如下:
res/anim/alpha.xml
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator" >
<alpha
android:duration="500"
android:fromAlpha="1.0"
android:startOffset="1000"
android:toAlpha="0.0" />
</set>
res/anim/scale.xml
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator" >
<scale
android:duration="2000"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0.0"
android:toYScale="0.0" />
</set>
res/anim/rotate.xml
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator" >
<rotate
android:duration="3000"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="+350" />
</set>
res/anim/translate.xml
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator" >
<translate
android:fromXDelta="50%"
android:toXDelta="100%"
android:fromYDelta="0%"
android:toYDelta="100%"
android:duration="2000"
/>
</set>
MainActivity.java
package com.xiaozhang.animationtest;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
public class MainActivity extends Activity {
private ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.imageViewId);
imageView = (ImageView) findViewById(R.id.imageViewId);
findViewById(R.id.rotateButtonId).setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
Animation animation = AnimationUtils.loadAnimation(
MainActivity.this, R.anim.rotate);
imageView.startAnimation(animation);
}
});
findViewById(R.id.scaleButtonId).setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
Animation animation = AnimationUtils.loadAnimation(
MainActivity.this, R.anim.alpha);
imageView.startAnimation(animation);
}
});
findViewById(R.id.alphaButtonId).setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
Animation animation = AnimationUtils.loadAnimation(
MainActivity.this, R.anim.scale);
imageView.startAnimation(animation);
}
});
findViewById(R.id.translateButtonId).setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
Animation animation = AnimationUtils.loadAnimation(
MainActivity.this, R.anim.translate);
imageView.startAnimation(animation);
}
});
}
}
不过需注意的是:
rotate.xml文件中android:pivotX的值共有三种设置方法:
1.android:pivotX="50" 这种方法使用绝对位置定位;
2.android:pivotX="50%" 这种方法相对于控件本身定位;
3.android:pivotx="50%p" 这种方法相对于控件的父控件定位;
(5)AnimationSet介绍:
AnimationSet是Animation的子类;一个AnimationSet包含了一系列的Animation;
为AnimationSet设置一些常见属性后,这些属性会应用到AnimationSet中的每一个Animation中;
多种效果的例子:

代码如下:
res/anim/alpha_scale.xml
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator" >
<alpha
android:duration="500"
android:fromAlpha="1.0"
android:startOffset="2000"
android:toAlpha="0.0" />
<rotate
android:duration="2000"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" />
<rotate
android:duration="2000"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="+350" />
<translate
android:duration="2000"
android:fromXDelta="0%"
android:fromYDelta="0%"
android:toXDelta="100%"
android:toYDelta="100%" />
</set>
MainActivity.java
package com.xiaozhang.animationtest;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
public class MainActivity extends Activity {
private ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.imageViewId);
imageView = (ImageView) findViewById(R.id.imageViewId);
findViewById(R.id.buttonId).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Animation animation = AnimationUtils.loadAnimation(
MainActivity.this, R.anim.alpha_scale);
imageView.startAnimation(animation);
}
});
}
}
也可以使用AnimationSet来实现:

代码:
package com.xiaozhang.animationtest;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;
public class MainActivity extends Activity {
private ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.imageViewId);
imageView = (ImageView) findViewById(R.id.imageViewId);
findViewById(R.id.buttonId).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// Animation animation = AnimationUtils.loadAnimation(
// MainActivity.this, R.anim.alpha_scale);
// imageView.startAnimation(animation);
AnimationSet animationSet = new AnimationSet(true);
AlphaAnimation alpha = new AlphaAnimation(1.0f, 0.0f);
RotateAnimation rotate = new RotateAnimation(0, 360,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);
animationSet.addAnimation(alpha);
animationSet.addAnimation(rotate);
// 动画执行过程 用时2秒
animationSet.setDuration(2000);
// 延迟一秒后,再执行程序
animationSet.setStartOffset(1000);
imageView.startAnimation(animationSet);
}
});
}
}
(6)Interpolator:定义了动画变化的速率,在Animations中有以下几种Interpolator;
AccelerateDelerateInterpolator,在动画开始与结束的地方速率改变比较慢,在中间的时间加速;
AccelerateInterpolator,在动画开始的地方速率比较慢,然后开始加速;
CycleInterpolator,动画循环播放特定的次数,速率改变沿着正弦曲线;
DecelerateInterpolator,在动画开始的地方速率改变比较慢,然后开始减速;
LinearInterolator,动画以均匀的速率改变;
在代码中可以这样设置:
AnimationSet animationSet = new AnimationSet(true);
animationSet
.setInterpolator(new AccelerateDecelerateInterpolator());
在XML文件中则是通过:
android:interpolator
(7)Frame-by-Frame Animations的使用方法
a)在res/drawable当中创建一个XML文件,用于定义Animations的动画序列;
b)为ImageView设置背景资源:imageView.setBackgroundResource(R.drawable.anim_pic);
c)通过ImageView得到AnimationDrawable:
AnimationDrawable animation = (AnimationDrawable) imageView .getBackground();
d)开始执行动画:animationDrawable.start();

代码如下:
MainActivity.java
package com.xiaozhang.animationtest;
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.ImageView;
public class MainActivity extends Activity {
private ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.imageViewId);
imageView = (ImageView) findViewById(R.id.imageViewId);
findViewById(R.id.buttonId).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
imageView.setBackgroundResource(R.drawable.anim_pic);
AnimationDrawable animation = (AnimationDrawable) imageView
.getBackground();
animation.start();
}
});
}
}
anim_pic.xml
<?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/pic1"
android:duration="800">
</item>
<item
android:drawable="@drawable/pic2"
android:duration="800">
</item>
<item
android:drawable="@drawable/pic3"
android:duration="800">
</item>
<item
android:drawable="@drawable/pic4"
android:duration="800">
</item>
<item
android:drawable="@drawable/pic5"
android:duration="800">
</item>
<item
android:drawable="@drawable/pic6"
android:duration="800">
</item>
<item
android:drawable="@drawable/pic7"
android:duration="800">
</item>
<item
android:drawable="@drawable/pic8"
android:duration="800">
</item>
<item
android:drawable="@drawable/pic9"
android:duration="800">
</item>
</animation-list>
activity_main.xml
<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"
tools:context="com.xiaozhang.animationtest.MainActivity" >
<Button
android:id="@+id/buttonId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="多张动画效果" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageViewId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginTop="100dp" />
</LinearLayout>
</RelativeLayout>
(8)LayoutAnimationController简介及使用:
a)LayoutAnimationController用于为一个layout里面的控件,或者是一个ViewGroup里面的控件设置动画效果;
b)每一个控件都有相同的动画效果;
c)这些控件的动画效果可以设置在不同的时间显示出来;
d)LayoutAnimationController可以在xml文件当中设置,也可以在代码中进行设置;
先看在XML文件中配置的效果:

具体步骤如下:
a)在res/anim文件夹中创建一个新文件,名为list_anim_layout.xml文件;
b)在布局文件中为ListView添加如下配置,目的是将动画效果应用到ListView上;
android:layoutAnimation="@anim/list_anim_layout"
代码如下:
layout/activity_main.xml
<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"
tools:context="com.xiaozhang.animationtest.MainActivity" >
<ListView
android:id="@id/android:list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutAnimation="@anim/list_anim_layout"
android:scrollbars="vertical" />
<Button
android:id="@+id/buttonId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/android:list"
android:text="test" />
</RelativeLayout>
anim/list_anim_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:animation="@anim/list_anim"
android:animationOrder="normal"
android:delay="0.5" />
动画样式list_anim.xml
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:shareInterpolator="true" >
<alpha
android:duration="2000"
android:fromAlpha="0.0"
android:toAlpha="1.0" >
</alpha>
</set>
ListView显示的内容:item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<TextView
android:id="@+id/user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25sp" />
<TextView
android:id="@+id/user_sex"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25sp" />
</LinearLayout>
再来看在代码中使用LayoutAnimationController:
a)创建一个Animation对象:可以通过装载XML文件,或者直接使用Animation的构造函数创建Animation对象;
b)使用如下代码创建LayoutAnimationController对象:
LayoutAnimationController lac = new LayoutAnimationController(animation);
c)设置控件显示的顺序:
lac.setOrder(LayoutAnimationController.ORDER_NORMAL);
d)为ListView设置LayoutAnimationController属性:
listView.setLayoutAnimation(lac);
效果和上面类似,只是反过来:

看代码:
activity_main.xml
<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"
tools:context="com.xiaozhang.animationtest.MainActivity" >
<ListView
android:id="@id/android:list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
<Button
android:id="@+id/buttonId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/android:list"
android:text="test" />
</RelativeLayout>
而MainActivity.java只需要修改onClick方法就行了;
public void onClick(View v) {
listView.setAdapter(buildListAdapter());
Animation animation = (Animation) AnimationUtils.loadAnimation(
MainActivity.this, R.anim.list_anim);
LayoutAnimationController lac = new LayoutAnimationController(
animation);
lac.setOrder(LayoutAnimationController.ORDER_REVERSE);
lac.setDelay(0.5f);
listView.setLayoutAnimation(lac);
}
(9)AnimationListener简单介绍
a)AnimationListener是一个监听器,该监听器在动画执行的各个阶段会得到通知,从而调用相应的方法;
b)主要有三个方法:
onAnimationStart(Animation animation)
onAnimationRepeat(Animation animation)
onAnimationEnd(Animation animation)
下面看一个使用AnimationListener添加和移除控件的例子:


activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layoutId"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.xiaozhang.animationtest.MainActivity" >
<Button
android:id="@+id/addButtonId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="添加动画" />
<Button
android:id="@+id/deleteButtonId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/addButtonId"
android:text="删除动画" />
<ImageView
android:id="@+id/imageViewId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:src="@drawable/icon" />
</RelativeLayout>
MainActivity.java
package com.xiaozhang.animationtest;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;
public class MainActivity extends Activity {
private ImageView imageView;
private ViewGroup viewGroup = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.imageViewId);
imageView = (ImageView) findViewById(R.id.imageViewId);
viewGroup = (ViewGroup) findViewById(R.id.layoutId);
findViewById(R.id.addButtonId).setOnClickListener(
new AddButtonListener());
findViewById(R.id.deleteButtonId).setOnClickListener(
new RemoveButtonListener());
}
class AddButtonListener implements OnClickListener {
@Override
public void onClick(View v) {
//创建一个淡入效果的Animation对象
AlphaAnimation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(2000);
animation.setStartOffset(500);
//创建一个新的ImageView
ImageView imageViewAdd = new ImageView(MainActivity.this);
imageViewAdd.setImageResource(R.drawable.icon);
//将新的ImageView添加到iewGroup中
viewGroup.addView(imageViewAdd, new LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
imageViewAdd.startAnimation(animation);
}
}
class RemoveButtonListener implements OnClickListener {
@Override
public void onClick(View v) {
// 创建一个淡出效果的Animation对象
AlphaAnimation animation = new AlphaAnimation(1.0f, 0.0f);
// 为Animation对象设置属性
animation.setDuration(1000);
animation.setStartOffset(500);
// 为Animation对象设置监听器
animation.setAnimationListener(new RemoveAnimationListener());
imageView.startAnimation(animation);
}
}
private class RemoveAnimationListener implements AnimationListener {
@Override
public void onAnimationStart(Animation animation) {
System.out.println("start");
}
// 该方法在淡出效果执行结束之后被调用
@Override
public void onAnimationEnd(Animation animation) {
System.out.println("end");
// 从ViewGroup中删除掉ImageView控件
viewGroup.removeView(imageView);
}
@Override
public void onAnimationRepeat(Animation animation) {
System.out.println("repeat");
}
}
}
Android Animations简介的更多相关文章
- Android Studio 简介及导入 jar 包和第三方开源库方[转]
原文:http://blog.sina.com.cn/s/blog_693301190102v6au.html Android Studio 简介 几天前的晚上突然又想使用 Android Studi ...
- "浅谈Android"第一篇:Android系统简介
近来,看了一本书,名字叫做<第一行代码>,是CSDN一名博主写的,一本Android入门级的书,比较适合新手.看了书之后,有感而发,想来进行Android开发已经有一年多了,但欠缺系统化的 ...
- 【译】Android系统简介—— Activity
续上一篇,继续介绍Android系统.上一篇: [译]Android系统简介 本文主要介绍构建Android应用的一些主要概念: Activity Activity是应用程序中一个单独的有UI的页面( ...
- 被遗忘的Android mipmaps简介
被遗忘的 Android mipmaps 简介 [导读]已经发布的 Android Studio1.1 版本是一个 bug 修复版本.在这个版本中,当你创建工程时一项改变将会吸引你的眼球.工程创建登陆 ...
- Android系统简介(中):系统架构
Android的系统架构栈分为4层,从上往下分别是Applications.Application framework.Libraries & Android Runtime.Linux ...
- Android系统简介(上):历史渊源
上个月,看到微信的一系列文章,讲到Linux的鼻祖-李纳斯的传记<Just for Fun>, 其人神乎其能, 其人生过程非常有趣,值得每个程序员细细品味. 而实际上,对我而已,虽然做软件 ...
- Android ART简介
一. Android ART简介 Android DEX/ODEX/OAT文件
- Android Animations 视图动画使用详解!!!
转自:http://www.open-open.com/lib/view/open1335777066015.html Android Animations 视图动画使用详解 一.动画类型 Andro ...
- Android插件简介
/** * @actor Steffen.D * @time 2015.02.06 * @blog http://www.cnblogs.com/steffen */ Android插件简介 Andr ...
随机推荐
- window下安装FTP服务器
系统window8.1 1.安装IIS组件:点开始菜单-选择控制面板--程序--打开或关闭WINDOWS功能--展开Internet信息服务,勾选FTP服务器(包括FTP服务和FTP扩展性),点确定. ...
- 再探java基础——对面向对象的理解(1)
对象 对象是人们要进行研究的任何事物,从最简单的整数到复杂的飞机等均可看作对象,它不仅能表示具体的事物,还能表示抽象的规则.计划或事件.对象具有属性和行为,在程序设计中对象实现了数据和操作的结合,使数 ...
- Parsing XML in J2ME
sun的原文,原文地址是http://developers.sun.com/mobility/midp/articles/parsingxml/. by Jonathan KnudsenMarch 7 ...
- Effective JavaScript Item 30 理解prototype, getPrototypeOf和__proto__的不同
本系列作为Effective JavaScript的读书笔记. prototype,getPropertyOf和__proto__是三个用来訪问prototype的方法.它们的命名方式非常类似因此非常 ...
- jQuery之简单动画效果
1. show()显示动画 语法:show(speed,callback) Number/String,Function speend为动画执行时间,单位为毫秒.也可以为slow",&quo ...
- api接口、RPC、WebService REST
RPC:所谓的远程过程调用 (面向方法) SOA:所谓的面向服务的架构(面向消息) REST:所谓的 Representational state transfer (面向资源) RPC 即远程过程调 ...
- angularjs金额大写过滤器
数字转中文 MyAppFilter.filter('rmbFilter',[function(){ function ChinaCost(input){ var numberValue=new Str ...
- 获取checkboxlist选中的值以及绑定来自之前选中的来自数据库的值
//////ps:一下几句都是一个意思,为的是以后有人搜索关键字的时候能定位到这里///checkboxlist绑定选中值///checkboxlist绑定来之mssql数据的值///checkbox ...
- 为什么class中属性以空格分隔?
1 div.contain .blue{color:blue;}/*后代选择器*/2 div.contain.blue{color:blue;} /*多类选择器*/ 以上两种规则分别应用的元素如下: ...
- C++ 知识点 2
基本类型常量 const int a; int const a; const int *a; int * const a; int const * a const; 之间的区别? const int ...