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

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

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

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

Xml属性

android:duration:运行动画的时间

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

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

方法:

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

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

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

Cancel():取消动画

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

initialize(int width, int height, int parentWidth, int parentHeight):初始化动画

reset():重置动画

Start()启动动画

其中还有一些常量

RESTART:重新运行

INFINITE:永无终止地运行

 

 

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

 

AnimationUtils类介绍

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

 

下面是一个实例 源码下载

 

Animationpage.xml是布局文件

    android:orientation="vertical"

    android:padding="10dip"

    android:layout_width="match_parent"

    android:layout_height="wrap_content">

    

    

    android:background="@drawable/a"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

       android:layout_marginBottom="10dip"

    />

 

    

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:textSize="26sp"

        android:text="震荡"

    />

 

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:flipInterval="2000"

         >


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部