Android Apps for Absolute Beginners

Page 175

CHAPTER 8: An Introduction to Graphics Resources in Android

1.

As shown in Figure 8–9, the first thing we must do is to import the Android classes that are going to be used in the text animation transformation: android.widget.TextView and the android.view.animation classes called Animation and AnimationUtils.

import android.widget.TextView; import android.view.animation.Animation; import android.view.animation.AnimationUtils;

Figure 8–9. Triggering our tween animation in our graphics.java code

2.

Then down in our onCreate() method, we specify the TextView object textAnim and the Animation object textAnimation.

TextView textAnim = (TextView) findViewById(R.id.TV1); Animation textAnimation = AnimationUtils.loadAnimation(this, R.anim.text_animation);

3.

We then call the startAnimation() method on the TextView object, specifying that we want to use the textAnimation Animation object.

textAnim.startAnimation(textAnimation);

4.

Finally, we need to add a TextView object named TV1 to our LinearLayout tag and UI container in our main.xml file, as shown in Figure 8–10.

www.it-ebooks.info

165


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.