AndroidAnimation动画(很详细)

更新时间:2023-05-11 06:30:29 阅读: 评论:0

AndroidAnimation动画(很详细)
展开全文
Android Animation
Contents:
Animations
Tween Animations
AnimationSet
Interpolator
Frame-By-Frame Animations
LayoutAnimationsController
AnimationListener
Animations
一、Animations介绍
Animations是一个实现android UI界面动画效果的APIAnimations提供了一系列的动画效果,可以进行旋转、缩放、淡入淡出等,这些效果可以应用在绝大多数的控件中。 
二、Animations的分类
Animations从总体上可以分为两大类:
1.Tweened Animations:该类Animations提供了旋转、移动、伸展和淡出等效果。Alpha——淡入淡出,Scale——缩放效果,Rotate——旋转,Translate——移动效果。
2.Frame-by-frame Animations:这一类Animations可以创建一个Drawable序列,这些Drawable可以按照指定的时间间歇一个一个的显示。
三、Animations的使用方法(代码中使用)
Animations extends Object implements Cloneable 
使用TweenedAnimations的步骤:
1.创建一个AnimationSet对象(Animation子类);
2.增加需要创建相应的Animation对象;
3.更加项目的需求,为Animation对象设置相应的数据;
4.Animatin对象添加到AnimationSet对象当中;
5.使用控件对象开始执行AnimationSet
Tweened Animations的分类
1、Alpha:淡入淡出效果
2、Scale:缩放效果
3、Rotate:旋转效果
4、Translate:移动效果
Animation的四个子类:
AlphaAnimation、TranslateAnimation、ScaleAnimation、RotateAnimation
四、具体实现
1l
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/rotateButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="旋转" />
<Button
android:id="@+id/scaleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="缩放" />
<Button
android:id="@+id/alphaButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="淡入淡出" />
<Button
android:id="@+id/translateButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="移动" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/an" />
</LinearLayout>
</LinearLayout>
2.java文件
importandroid.app.Activity;
importandroid.os.Bundle;
importandroid.view.View;
importandroid.view.View.OnClickListener;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
importandroid.view.animation.AnimationSet;
importandroid.view.animation.RotateAnimation;
importandroid.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;
importandroid.widget.Button;
importandroid.widget.ImageView;
public class Animation1Activity extends Activity {
private Button rotateButton = null;
private Button scaleButton = null;
private Button alphaButton = null;
private Button translateButton = null;
private ImageView image = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
tContentView(R.layout.main);
rotateButton = (Button)findViewById(R.id.rotateButton);
scaleButton = (Button)findViewById(R.id.scaleButton);
alphaButton = (Button)findViewById(R.id.alphaButton);
translateButton = (Button)findViewById(R.id.translateButton);
image = (ImageView)findViewById(R.id.image);
rotateButton.tOnClickListener(newRotateButtonListener());
scaleButton.tOnClickListener(newScaleButtonListener());
alphaButton.tOnClickListener(newAlphaButtonListener());

本文发布于:2023-05-11 06:30:29,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/581744.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:效果   对象   使用   相应
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图