Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 561
Whady Avatar asked Jan 12 '13 02:01

Whady


People also ask

What are the two different types of view animations in Android?

The animations are basically of three types as follows: Property Animation. View Animation. Drawable Animation.


1 Answers

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.

like image 52
Karthik Balakrishnan Avatar answered Oct 11 '22 23:10

Karthik Balakrishnan