Last active
May 5, 2021 11:44
-
-
Save patrick-elmquist/3ee57efed2f871e60d8723aabf7bd1ef to your computer and use it in GitHub Desktop.
Enter animation demo: Re run LayoutAnimation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void runLayoutAnimation(final RecyclerView recyclerView) { | |
| final Context context = recyclerView.getContext(); | |
| final LayoutAnimationController controller = | |
| AnimationUtils.loadLayoutAnimation(context, R.anim.layout_animation_fall_down); | |
| recyclerView.setLayoutAnimation(controller); | |
| recyclerView.getAdapter().notifyDataSetChanged(); | |
| recyclerView.scheduleLayoutAnimation(); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, the demo code at Github has actually been re-written in Kotlin as of Part 3 of the tutorial, so you could check out ListDemoFragment for some ideas:
https://github.com/patrick-elmquist/Demo-RecyclerViewEnterAnimation/blob/master/app/src/main/java/com/patrickiv/demo/enteranimationdemo/fragment/ListDemoFragment.kt#L70
Doing it now, I would probably add an extension function instead, like this:
and invoke it like
recyclerView.runLayoutAnimation().Gonna update the blog posts with Kotlin as well when I get the time.