Listing 311 Example of an animation defined in an XML resource scalerxml

<?xml version="1.0" encoding="utf- 8 " ?>

<scale xmlns:android="http://schemas.android.com/apk,___,________

android:fromXScale="0.5" android:toXScale="2.0" android:fromYScale="0.5" android:toYScale="2.0" android:pivotX="5 0%" android:pivotY="5 0%" android:startOffset="700" android:duration="4 00" android:fillBefore="false" />

In code you can reference and use this animation with any View object (TextView, for example) as follows:

view.startAnimation(AnimationUtils.loadAnimation(this, R.anim.scaler));.

This will scale O the view element up in size on both the X and Y axes. Though we do not have any animations in the RestaurantFinder sample application by default, to see this work you can simply add the startAnimation method to any view element in the code and reload the application. Animations can come in handy, so you should be aware of them. We will cover animations and other graphics topics in detail in chapter 9.

With our journey through Android resources now complete, we next need to address the final aspect of RestaurantFinder we have yet to cover, the AndroidMani-fest.xml manifest file, which is required for every Android application.

0 0

Post a comment