Tuesday, July 9, 2013

How to Create Animation In Android

The Android Development Tutorials blog contains Basic as well as Advanced android tutorials.Go to Android Development Tutorials to get list of all Android Tutorials.

Android Animation


We can animate all the views like Layouts, TextViews,ImageViews, Buttons etc. Animation makes the GUI  more interactive and enhance User Experience.

Android offers two kinds of animation:
Frame-by-Frame Animations are  Traditional cell-based animations in which a different Drawable
is displayed in each frame. Frame-by-frame animations are displayed within a View,
using its Canvas as a projection screen.
Tweened Animations Tweened animations are applied to Views, letting you define a series
of changes in position, size, rotation, and opacity that animate the View contents.

Android Custom Alert Dialog Example

Note: Both animation types are restricted to the original bounds of the View they’re  applied to.   Rotations, translations, and scaling transformations that extend beyond
the original boundaries of the View will result in the contents being clipped.


 Tweened Animations

Tweened animations offer a simple way to provide depth, movement, or feedback to your users at a
minimal resource cost.
Using animations to apply a set of orientation, scale, position, and opacity changes is much less
resource-intensive than manually redrawing the Canvas to achieve similar effects, not to mention far
simpler to implement.

Tweened animations are commonly used to:
➤ Transition between Activities.
➤ Transition between layouts within an Activity.
➤ Transition between different content displayed within the same View.
➤ Provide user feedback such as:
➤ Indicating progress.
➤ ‘‘Shaking’’ an input box to indicate an incorrect or invalid data entry.
Creating Tweened Animations
Tweened animations are created using the Animation class. The following list explains the animation
types available.
➤ AlphaAnimation Lets you animate a change in the View’s transparency (opacity or alpha
blending).
➤ RotateAnimation Lets you spin the selected View canvas in the XY plane.
➤ ScaleAnimation Allows you to zoom in to or out from the selected View.
➤ TranslateAnimation Lets you move the selected View around the screen (although it will
only be drawn within its original bounds).

Android offers the AnimationSet class to group and configure animations to be run as a set. You can
define the start time and duration of each animation used within a set to control the timing and order
of the animation sequence.
It’s important to set the start offset and duration for each child animation, or they will all start and complete at the same time.

Animating Layouts and View Groups

A LayoutAnimation is used to animate View Groups, applying a single Animation (or Animation Set)
to each child View in a predetermined sequence.
Use a LayoutAnimationController to specify an Animation (or Animation Set) that’s applied to each
child View in a View Group. Each View it contains will have the same animation applied, but you can
use the Layout Animation Controller to specify the order and start time for each View.
Android includes two LayoutAnimationController classes.
LayoutAnimationController Lets you select the start offset of each View (in milliseconds)
and the order (forward, reverse, and random) to apply the animation to each child View.
GridLayoutAnimationController Is a derived class that lets you assign the animation
sequence of the child Views using grid row and column references.


Following are Examples of Animating diffrent types of Views

Android Animation Examples:


Animating  ImageViews




Layout Animations


More Android Topics

New Advance Topics:
Android ImageSwitcher                    Android TextSwitcher                                Android ViewFlipper
Android Gesture Detector               Handling/Detecting Swap Events                Gradient Drawable
Detecting Missed Calls                    Hide Title Bar                                           GridView Animation

 Beginning With Android
      Android : Introduction                                                              Configuring Eclipse for Android Development
     Creating Your First Android Project                                           Understanding Android Manifest File of your android app

 Advance Android Topics                                                              Customizing Android Views


Working With Layouts                                                                Working With Views

Understanding Layouts in Android                                                   Using Buttons and EditText in Android
Working with Linear Layout (With Example)                                     Using CheckBoxes in Android
Nested Linear Layout (With Example)                                              Using AutoCompleteTextView in Android                                                                                          Grid View
Relative Layout In Android                                                               ListView
Table Layout                                                                                   Android ProgressBar
Frame Layout(With Example)                                                          Customizing ProgressBar
Absolute Layout                                                                             Customizing Radio Buttons
Grid Layout                                                                                    Customizing Checkboxes In Android

Android Components                                                                 Dialogs In Android

Activity In Android                                                                    Working With Alert Dialog
Activity Life Cycle                                                                    Adding Radio Buttons In Dialog
Starting Activity For Result                                                       Adding Check Boxes In Dialog
Sending Data from One Activity to Other in Android                    Creating Customized Dialogs in Android
Returning Result from Activity                                                   Creating Dialog To Collect User Input
Android : Service                                                                     DatePicker and TimePickerDialog
BroadcastReceiver                                                                   Using TimePickerDialog and DatePickerDialog In android

Menus In Android                                                                ListView:
Creating Option Menu                                                               Populating ListView With DataBase
Creating Context Menu In Android                                              Populating ListView with ArrayList
                                                                                               ListView with Custom Adapter

Toast                                                                                      Working With SMS
Customizing Toast In Android                                                       How to Send SMS in Android
Customizing the Display Time of Toast                                        How To Receive SMS
Customizing Toast At Runtime                                                  Accessing Inbox In Android
Adding Image in Toast
Showing Toast for Longer Time


TelephonyManager                                                            Storage: Storing Data In Android
Using Telephony Manager In Android                                          SharedPreferences In Android
                                                                                              Reading and Writing files to Internal Stoarage
Working With Incoming Calls                                             DataBase
How To Handle Incoming Calls in Android                                Working With Database in Android
How to Forward an Incoming Call In Android                            Creating Table In Android
CALL States In Android                                                          Inserting, Deleting and Updating Records In Table in Android


Miscellaneous
Notifications In Android
How To Vibrate The Android Phone
Sending Email In Android
Opening a webpage In Browser
How to Access PhoneBook In Android
Prompt User Input with an AlertDialog





2 comments: