Android, make an animation text scroll up on the screen like first part of Star Wars

做~自己de王妃 提交于 2019-12-10 17:23:05

问题


I'm trying to create an animation in my android app.

I want the animation like the credits of Star Wars the movie, where a text goes up gradually. If there is another way to do it than I'd like to know.


回答1:


Try this :

Put this piece of code in an xml file in res/anim/animationfile.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>

Now to set the animation, do this :

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

This is how you do it roughly.




回答2:


here is a very good example of animation for u

http://android-er.blogspot.com/2012/02/various-effect-of-interpolator-in.html



来源:https://stackoverflow.com/questions/14289565/android-make-an-animation-text-scroll-up-on-the-screen-like-first-part-of-star

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!