首頁  >  文章  >  web前端  >  Android ViewAnimation(tween animation补间动画)文档教程_html/css_WEB-ITnose

Android ViewAnimation(tween animation补间动画)文档教程_html/css_WEB-ITnose

WBOY
WBOY原創
2016-06-24 11:40:29893瀏覽

XML注意事项:

在res/anim/目录下,XML文件只能有 中一个根元素,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。

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn