Building List and Grid Layout With RecyclerView in Android using Java

What Is Recycler View?

In this post, We build List and Grid With RecyclerView.

In Older way we were use ListView (Verticle & Horizontal) and GridView. But Material Design as google suggested we have to start Using RecyclerView. Advantage of RecyclerView is we can create list and grid by changing it’s LayoutManager Property.

Let’s understand RecyclerView With Movie List Example then we show movie list in

KeyPoints of RecyclerView

RecyclerView Adapter

LayoutManager

ItemDecoration

RecyclerView Adapter

RecyclerView Adapter is Similar to BaseAdapter that Use in ListView Or GridView But RecyclerViewAdapter is more extended Version Of it and more powerfull than BaseAdapter. You can read More Details from RecyclerViewAdapter.

RecyclerView Adapter Sample Given Below

1

CODE Of Adapter Sample Gits

LayoutManager

A LayoutManager is responsible for measuring and positioning item views within a RecyclerView as well as determining the policy for when to recycle item views that are no longer visible to the user. By changing the LayoutManager a RecyclerView can be used to implement a standard vertically scrolling list, a uniform grid, staggered grids, horizontally scrolling collections and more. Several stock layout managers are provided for general use.

Type of Layoutmanager

LinearLayoutManager

GridLayoutManager

StaggeredGridLayoutManager

LinearLayoutManager

It is sub class of layoutManager class and shows items in a vertical or horizontal scrolling list also support reverse layout.