Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android animateLayoutChanges: can I set a listener?

I have set android:animateLayoutChanges to true for my LinearLayout:

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:gravity="top"
        android:animateLayoutChanges="true">
</LinearLayout>

Then, I run the following to animate the disappearance of an element.

TextView line;
...
line.setVisibility(View.GONE);

How can I know when the animation has finished?

like image 701
Daniels Šatcs Avatar asked Mar 08 '16 12:03

Daniels Šatcs


1 Answers

Same question to me, this post will help you. https://stackoverflow.com/a/17869028

First, get LayoutTransition from LinearLayout using getLayoutTransition method. Then add TransitionListener to layout transition you got.

This method available for api-level 11 and above.

like image 61
Taiwanese Avatar answered Nov 06 '22 17:11

Taiwanese