Date post: | 22-Jan-2018 |
Category: |
Software |
Upload: | shilu-shrestha |
View: | 363 times |
Download: | 0 times |
Basic View Animation
in AndroidBy Shilu Shrestha
Pre-requisites
• Installed well functioning Android Studio
• Basic knowledge of programming in Android is a
plus
animationanɪˈmeɪʃ(ə)n/
noun
the state of being full of life or vigour;
liveliness.
Why do we need
Animation in Android?
• Notify when screen changes its state; Such as
when content load is complete.
• Communicate quickly and concisely with your user.
• Adds a polished finished look to your app.
Animation in Android
Property Animation
• A property animation changes a property's (a field in
an object) value over a specified length of time.
• Property animation allows you to animate almost
anything.
View Animation
• Tween Animation
• Frame Animation
Tween Animation
• Perform a series of simple transformations
(position, size, rotation, and transparency) on the
contents of a View object.
• Calculates the animation with information such as
the start point, end point, size, rotation, and other
common aspects of an animation.
• Can be done using XML or Programmatically
Animation using XML File
• Like all xml there should be one root file
• File location:
• res/anim
• The elements performing xml animations are
• <alpha>
• <scale>
• <rotate>
• <translate>
• Animation elements maybe grouped using <set> element.
• <alpha> : fade in / fade out
• <android:fromAlpha>
• <android:toAlpha>
• “1.0" : opaque
• “0.0” : transparent
• <scale> : resize image
• <android:fromXScale>
• <android:toXScale>
• <android:fromYScale>
• <android:toYScale>
• <android:pivotX>
• <android:pivotY>
• <rotate> : rotation animation
• <android:fromDegrees>
• <android:toDegrees>
• <android:pivotX>
• <android:pivotY>
• <translate> : a vertical or horizontal translation
• <android:fromXDelta>
• <android:toXDelta>
• <android:fromYDelta>
• <android:toYDelta>
Demo
Animation Listener
• Animation listener receives notifications from
animation.
• onAnimationStart (Animation animation)
• onAnimationRepeat (Animation animation)
• onAnimationEnd (Animation animation)
Animation using Java Code
Demo
Frame Animation
• An animation defined in XML which shows the
sequence of images in order.
• File location:
• res/drawable/<filename>.xml
• Elements
• <animation-list> : root element contains list of
<item>
• <android:oneshot> : attribute to loop animation
Demo
Some Ideas
• Final Repo: https://github.com/shilu-stha/Basic-
Animations
Thank-you