Android animation

872 views
665 views

Published on

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
872
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
17
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Android animation

  1. 1. Mobile Computing – 650003 MCA – ISTAR, V.V. Nagar 1Mr. Pritesh N. Patel (ISTAR)
  2. 2. Types of Animation Android support following types of animation 1. Animated GIF files 2. Frame-by-Frame Animation 3. Tweened Animation 2Mr. Pritesh N. Patel (ISTAR)
  3. 3.  In these type of animation, a series of similar images displayed in sequence, each image is different from one another from first to last.  It display images so quickly by giving illusion of moving animation.  These type of animation is used when transformation is not easy with programming. Code Sample 3Mr. Pritesh N. Patel (ISTAR) Frame-by-Frame Animation
  4. 4.  In these type of animation, animation can perform simple transformation on the content of view.  Transformation can be position, size, rotation and transparency.  The animation package provide all the classes used in tween animation like RotateAnimation, ScaleAnimation, Transformation, TranslateAnimation, etc.  We can also provide transformation to any view. Code Sample 4Mr. Pritesh N. Patel (ISTAR) Tweened Animation
  5. 5.  We can define animation programmatically using classes available in android.view.animation package. For e.g. to define rotation RotateAnimation r = new RotateAnimation( 0, 360, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); r.setDuration(500); 5Mr. Pritesh N. Patel (ISTAR) Define Tweened Animation Programmatically
  6. 6.  RotateAnimation (float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)  ScaleAnimation (float fromX, float toX, float fromY, float toY, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)  TranslateAnimation (int fromXType, float fromXValue, int toXType, float toXValue, int fromYType, float fromYValue, int toYType, float toYValue) 6Mr. Pritesh N. Patel (ISTAR) Syntax:
  7. 7.  We can define animation as XML resource at file location res/anim/my_anim.xml like (see syntax in given doc file) <set android:interpolator="@android:anim/accelerate_interp olator” android:startOffset="700"> <rotate android:fromDegrees="0" android:toDegrees="-45" android:toYScale="0.0" android:pivotX="50%" android:pivotY="50%" android:duration="400" /> </set> 7Mr. Pritesh N. Patel (ISTAR) Define Tweened Animation as XML Resource

×