【发布时间】:2012-12-26 16:59:49
【问题描述】:
我正在尝试在我的 android 应用中创建动画。
我想要动画,就像电影《星球大战》的演职员表,文字逐渐上升。如果有其他方法可以做到这一点而不是我想知道的。
【问题讨论】:
-
最后,是否需要重启、停止、循环?
我正在尝试在我的 android 应用中创建动画。
我想要动画,就像电影《星球大战》的演职员表,文字逐渐上升。如果有其他方法可以做到这一点而不是我想知道的。
【问题讨论】:
试试这个:
将这段代码放在res/anim/animationfile.xml中的一个xml文件中
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator" >
<translate
android:duration="5000" ---> set your time here
android:fromYDelta="-100%p"
android:toYDelta="100%p" /> </set>
现在要设置动画,这样做:
Animation translatebu= AnimationUtils.loadAnimation(this, R.anim.animationfile);
tv.setText("Some text view.");
tv.startAnimation(translatebu);
这就是你粗略的做法。
【讨论】:
res/anim 并创建 animationfile.xml 并将代码放在那里。对于您想要应用动画的任何小部件,您可以使用widgetIdentifier.startAnimation(trnaslatebu);
repeatCount和repeatMode。
【讨论】: