Skip to content

Custom Layout Animations

rutura edited this page Apr 16, 2017 · 1 revision
  • API Level 11

  • Using a custom Layout animation

  • Use these to apply custom animations to layout changes

  • There are five states of layout changes for which you can

  • apply a custom animation on different states:

    • APPEARING: An item that is appearing in the container
    • DISAPPEARING: An item that is disappearing from the container
    • CHANGING: An item that is changing because of a layout change, such as a resize, that doesn’t involve views being added or removed
    • CHANGE_APPEARING: An item changing because of another view appearing
    • CHANGE_DISAPPEARING: An item changing because of another view disappearing
  • In this example APPEARING, DISAPPEARING and CHANGE_DISAPPEARING are used.

  • How to use these:

          #Create a LayoutTransition and attach it to a view(Layout)
                LayoutTransition transition = new LayoutTransition();
                mContainer.setLayoutTransition(transition);

          #Create Animators and apply them to the states you are interested
           in customizing:
                    Animator appearAnim = ObjectAnimator.ofFloat(null,
                "rotationY", 90f, 0f).setDuration(
                transition.getDuration(LayoutTransition.APPEARING));
                transition.setAnimator(LayoutTransition.APPEARING, appearAnim);
Clone this wiki locally