Search code examples
androidperformanceandroid-recyclerviewgrid-layoutandroid-gridlayout

GridLayout vs. RecyclerView with GridLayoutManager


I am just starting with Android development and there are at least two ways to build a grid: using GridLayout or using a RecyclerView with a GridLayoutManager.

  • Is there any case/reason still to use a GridLayout?
  • Is it maybe faster at rendering/loading, as it maybe is simpler?

I want to build a grid of cards, likely around max. 50 cards.


Solution

  • It's absolutely fine to just use GridLayout if you don't need the functionality of the RecyclerView. Nevertheless, you should get involved with the RecyclerView asap(it's a very strong tool).

    Up to a certain size, the solo GridLayout will render/load faster but at some point, this effect will reverse:

    Recycle (view): A view previously used to display data for a specific adapter position may be placed in a cache for later reuse to display the same type of data again later. This can drastically improve performance by skipping initial layout inflation or construction.