Noa Drach
Noa Drach

Reputation: 2481

Android - LayoutTransition hides views inside the animated view before closing it

I have a LinearLayout that contains several views - when I add or remove it from my view I used the default LayoutTransition.

I'm adding the view to my AppbarLayout - and I added the animations programmatically by setting a new LayoutAnimation on the appbar before adding the view and setting it to null after the view is added - I don't do it using the tag in the xml due to https://code.google.com/p/android/issues/detail?id=191170

The problem is that when i remove it from the view the default animation is done in two parts

  1. all the views inside immediately disappear
  2. the closing of the view is animated from bottom to top

Which change is needed to the LayoutTransition in order to have only the 2nd animation where the view is closed from bottom to top?

Upvotes: 0

Views: 358

Answers (2)

Vitaly Zinchenko
Vitaly Zinchenko

Reputation: 4911

Try this:

final LinearLayout container = (LinearLayout) findViewById(R.id.container);
LayoutTransition transition = container.getLayoutTransition();
transition.disableTransitionType(LayoutTransition.APPEARING);
transition.disableTransitionType(LayoutTransition.DISAPPEARING);

Upvotes: 0

tkos kostas
tkos kostas

Reputation: 3

CommonsWare answer

Modify its LayoutParams to move it to the end position. Use getLayoutParams() on the View, cast it to the appropriate type based on its container, modify the LayoutParams object, then call setLayoutParams() on the View to commit the changes.

Upvotes: 0

Related Questions