Lecture Presentation

Lecture Presentation


  • Animate Views in your interface


  • Android has two APIs for animating views
    • View animations before version 3.0
    • Property animations from version 3.0
  • Animation situations
    • Single view to animate
    • Layout animations when new child views are added
    • Activity animations when switching between activities

View animations

  • Steps
    • Create object for specific type of animation
    • Set extra properties for the animation
    • Start the animation on a View object
  • Types of View animations
    • ScaleAnimation
      • Changing the width and/or height
    • TranslateAnimation
      • Changing the position in x and/or y coordinates
    • AlphaAnimation
      • Changing the transparency of the view
    • RotateAnimation
      • Changing the rotation of the view
  • Note that the clickable area always stays the same when animating

Create and start a View animation

  • Example
    TranslateAnimation anim = new TranslateAnimation(-_text.getWidth(), 0, 0, 0);
    anim.setInterpolator(new DecelerateInterpolator());
  • Specification to constructor
    • Start x offset
    • End x offset
    • Start y offset
    • End y offset

More animation properties

  • Interpolator