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

2

7

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.

Impede answered 12/1, 2013 at 2:25 Comment(1)
at the end, does it need to restart, stop, or loop ?Prescind
K
13

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.

Kaspar answered 12/1, 2013 at 2:38 Comment(5)
thanks man, but how should be the animation file?, where can i do that animation? sorry, i have no idea about this, please guide me @TorcelliteImpede
@Impede You put the xml code in a the path I've given there res/anim and create animationfile.xml and put the code there. And to whatever widget you want to apply the animation to, you use widgetIdentifier.startAnimation(trnaslatebu);Kaspar
when it reaches the end, does it loops ? or restarts, stops?. What does this needs to make it loop ?Prescind
@FranciscoCorralesMorales - Take a look at this developer.android.com/reference/android/view/animation/…, specifically read repeatCount and repeatMode.Kaspar
Shouldn't a star wars text also be "tilted" into a trapezoid shape ? How do you do this?Venlo
G
2

here is a very good example of animation for u

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

Grandnephew answered 12/1, 2013 at 3:40 Comment(2)
ok, but how can I make it loop ?, like a cycle but keep in the same direction....Prescind
you just add to animation xml file android:repeatCount="infinite"Grandnephew

© 2022 - 2024 — McMap. All rights reserved.