首页 > 移动平台 > 详细

Android ViewAnimation(tween animation补间动画)文档教程

时间:2015-07-24 18:18:51      阅读:268      评论:0      收藏:0      [点我收藏+]

XML注意事项:

在res/anim/目录下,XML文件只能有 <alpha><scale><translate><rotate>中一个根元素,set标签下默认动画同时进行,想要顺序进行需要startOffset元素。

注意pivotX动画中X的中间坐标,如旋转:50是指相对父View的50%,50%是相对自身View的50%

例子:

<set android:shareInterpolator="false">
    <scale
        android:interpolator="@android:anim/accelerate_decelerate_interpolator"
        android:fromXScale="1.0"
        android:toXScale="1.4"
        android:fromYScale="1.0"
        android:toYScale="0.6"
        android:pivotX="50%"
        android:pivotY="50%"
        android:fillAfter="false"
        android:duration="700" />
    <set android:interpolator="@android:anim/decelerate_interpolator">
        <scale
           android:fromXScale="1.4"
           android:toXScale="0.0"
           android:fromYScale="0.6"
           android:toYScale="0.0"
           android:pivotX="50%"
           android:pivotY="50%"
           android:startOffset="700"
           android:duration="400"
           android:fillBefore="false" />
        <rotate
           android:fromDegrees="0"
           android:toDegrees="-45"
           android:toYScale="0.0"
           android:pivotX="50%"
           android:pivotY="50%"
           android:startOffset="700"
           android:duration="400" />
    </set>
</set>


ImageView spaceshipImage = (ImageView) findViewById(R.id.spaceshipImage);
Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(this, R.anim.hyperspace_jump);
spaceshipImage.startAnimation(hyperspaceJumpAnimation);

想在特定时间开始动画,可以使用 Animation.setStartTime()方法,通过View.setAnimation().方法设置给View。

Android ViewAnimation(tween animation补间动画)文档教程

原文:http://blog.csdn.net/zhjali123/article/details/47044295

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!