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.

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
Whady
  • 135
  • 1
  • 3
  • 11

2 Answers2

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.

Karthik Balakrishnan
  • 4,353
  • 6
  • 37
  • 69
  • 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 @Torcellite – Whady Jan 12 '13 at 04:07
  • @Whady 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);` – Karthik Balakrishnan Jan 12 '13 at 04:32
  • when it reaches the end, does it loops ? or restarts, stops?. What does this needs to make it loop ? – Francisco Corrales Morales Nov 28 '14 at 23:17
  • 1
    @FranciscoCorralesMorales - Take a look at this http://developer.android.com/reference/android/view/animation/Animation.html, specifically read `repeatCount` and `repeatMode`. – Karthik Balakrishnan Nov 29 '14 at 06:08
  • Shouldn't a star wars text also be "tilted" into a trapezoid shape ? How do you do this? – android developer Aug 25 '15 at 08:12
2

here is a very good example of animation for u

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

Mohammed Asmar
  • 308
  • 2
  • 5
  • 21