Home  >  Article  >  Web Front-end  >  Android ViewAnimation(tween animation补间动画)文档教程_html/css_WEB-ITnose

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

WBOY
WBOYOriginal
2016-06-24 11:40:29893browse

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。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn