Search code examples
androidsectionedrecyclerviewadapter

SectionedRecyclerViewAdapter animations


I have been using SectionedRecyclerViewAdapter from https://github.com/luizgrp/SectionedRecyclerViewAdapter. It is working great. I would like to start adding some animations. I downloaded and installed the test/example app, and inspected the code for the animation example. I cannot understand what part of the code for the example makes the animations work as they do. Can anyone explain it?


Solution

  • Animations are triggered when any of the notify methods of the RecyclerView.Adapter are called. In the example below the RecyclerView will animate the insertion of an item in a specific position:

    adapter.notifyItemInserted(position);
    

    The library provide extra notify methods to help trigger the animation for specific items of the sections, like this one.