Transition.allLayout() allows easily animating all layout changes, without having to assign transitionKeys to all Components

1
2
3
4
@OnCreateTransition
static Transition onCreateTransition(ComponentContext c) {
  return Transition.allLayout().animator(ANIMATOR);
}

Note, that Transition.allLayout():

  1. Targets AnimatedProperty.X, Y, HEIGHT and WIDTH of all Components present in layout tree.
  2. Could be used to define transitions of change type only. For defining appearing and disappearing transitions, transitionKeys still need to be assigned.
  3. Could be used as a part of more complex choreography.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
@OnCreateTransition
static Transition onCreateTransition(ComponentContext c) {
  return Transition.parallel(
      Transition.allLayout().animator(ANIMATOR),
      Transition.create(TRANSITION_KEY_TEXT)
          .animate(AnimatedProperties.WIDTH)
          .appearFrom(0f)
          .disappearTo(0f)
          .animator(ANIMATOR),
      Transition.create(TRANSITION_KEY_TEXT)
          .animate(AnimatedProperties.ALPHA)
          .appearFrom(0f)
          .disappearTo(0f)
          .animator(ANIMATOR));
}

Edit on GitHub