700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > Android开发之动画源码Animation详细分析

Android开发之动画源码Animation详细分析

时间:2021-08-06 03:02:17

相关推荐

Android开发之动画源码Animation详细分析

Android开发之动画源码详细分析

Animation是一个用于View,Surfaces和其它对象实现动画效果的抽象类,其中常用的类是TranslateAnimation用于控制位置的改变

一下列出一些重要的属性和方法

Xml属性

android:duration:运行动画的时间

android:interpolator:定义用于平滑动画运动的时间内插

android:repeatCount:定义动画重复的时间

方法:

set:RepeatCount(int):定义动画重复的时间

setRepeatMode(int):通过设置重复时间定义动画的行为

setStartOffset(long):以毫秒为单位的动画运行前的延迟,一旦开始时间就达到了

Cancel():取消动画

hasStarted():判断动画是否已在运行

initialize(intwidth,intheight,intparentWidth,intparentHeight):初始化动画

reset():重置动画

Start()启动动画

其中还有一些常量

RESTART:重新运行

INFINITE:永无终止地运行

将动画用于指定的控件,所有继承自View的控件都有startAnimation(Animation)方法,通过调用此方法来应用动画于控件

AnimationUtils类介绍

为应用动画提供了通用的的方法,它有一个很重要的方法loadAnimation(Context,Animation)用于加载Animation的实例。

下面是一个实例源码下载

Animationpage.xml是布局文件

<?xmlversion="1.0"encoding="utf-8"?>

<LinearLayoutxmlns:android="/apk/res/android"

android:orientation="vertical"

android:padding="10dip"

android:layout_width="match_parent"

android:layout_height="wrap_content">

<ImageViewandroid:id="@+id/pw"

android:background="@drawable/a"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_marginBottom="10dip"

/>

<Buttonandroid:id="@+id/login"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:textSize="26sp"

android:text="震荡"

/>

<ViewFlipperandroid:id="@+id/flipper"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:flipInterval="2000"

>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。