

So, in onCreate, if the SDK version is older than Lollipop, the RecyclerView is populated: But from Lollipop, we can use onEnterAnimationComplete to check that. For versions previous to Lollipop you can’t do much, there is not (or at least I didn’t find) and effective way to know when the enter transition finished. If you just execute like this, you’ll see that while the app is opening, the layout animation is executed, so you can’t really see the animation taking effect. This is the XML of the slide in animation: – direction: it specifies how the items appear based on the column delay: top_to_bottom, left_to_right, bottom_to_top, and right_to_left are the possible values. – animationOrder: It can be normal, reverse or random. I’m using an animation that slides in from the bottom of the screen. – animation: the animation that will be used to make the views appear in the screen. That way we can specify that the next views in the row and the column are animated one after the other, instead of appearing all of them at the same time.

– columnDelay / rowDelay: the percent of the time the elements of the rows and columns will be delayed when animating them. We can customize the animation as we prefer: We just need to define an XML with the corresponding layout animation: The good thing about layout animations is that we can define them and assign them through XML, so our code is not altered by the inclusion of the animation. The problem is that RecyclerView doesn’t use layout animations by default, but this code makes it able to use GridLayoutAnimations as a GridView would do. But when looking for solutions, I found this awesome gist from Musenkishi that gave me the solution. I must admit I haven’t used layout animations much, so this option didn’t come up to my mind instantly. In the end, the solution was simpler than expected. It’s really difficult to make it work properly. But the code is rather delicate and intrusive (we are adding animations inside the adapter). Another one, which in fact works, consists of animating the elements in onBind() only when necessary. But this method doesn’t give much control about the order of animation, so didn’t seem like a good solution. One solution, that a lot of people mentions, is to use the RecyclerView::notifyItemInserted() method. I’ve been trying all the alternatives to get that behaviour. If you haven’t seen it, it consists of a diagonal animation that populates the activity from top to bottom and from left to right. Since Material Design was presented, I’ve been amazed by the animations some videos showed when populating a grid.
