Android,让动画文字像星球大战的第一部分一样在屏幕上向上滚动

Wha*_*ady 4 animation android credits

我正在尝试在我的Android应用程序中创建动画.

我希望动画像电影中的星球大战的演职员表,文字逐渐上升.如果有另一种方法可以做到这比我想知道的那样.

Kar*_*nan 11

试试这个 :

将这段代码放在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>
Run Code Online (Sandbox Code Playgroud)

现在要设置动画,请执行以下操作:

Animation translatebu= AnimationUtils.loadAnimation(this, R.anim.animationfile);
tv.setText("Some text view.");
tv.startAnimation(translatebu);
Run Code Online (Sandbox Code Playgroud)

这是你大致如何做到的.