GridLayout 与 RecyclerView 与 GridLayoutManager

GridLayout vs. RecyclerView with GridLayoutManager

我刚刚开始 Android 开发,至少有两种构建网格的方法:使用 GridLayout or using a RecyclerView with a GridLayoutManager

我想构建一个卡片网格,可能在最大值附近。 50 张卡片。

如果不需要 RecyclerView 的功能,只使用 GridLayout 绝对没问题。尽管如此,您还是应该尽快使用 RecyclerView(这是一个非常强大的工具)。

达到一定大小后,单独的 GridLayout 会 render/load 更快,但在某些时候,这种效果会逆转:

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.