Skip to main content

What is RecyclerView in Android?

RecyclerView in Android

RecyclerView in Android
Hello world, today we are going to learn what is recyclerview, what are its advantages, and what are recyclerview examples? Let's start...

What is RecyclerView?

RecyclerView helps us to make a repetitive and group of views. It can be a list of views in the form of a list view or in the gird type of view. Think it about as a loop of views where you can populate your data dynamically in the child's views. Recyclerview can be used as a listview of textview but with different text. You can also use cardview with recyclerview to make your UI look professional.

According to the android official site, what is recyclerview?

The RecyclerView widget is a more advanced and flexible version of ListView.

In the RecyclerView model, several different components work together to display your data. The overall container for your user interface is a RecyclerView object that you add to your layout. The RecyclerView fills itself with views provided by a layout manager that you provide. You can use one of our standard layout managers (such as LinearLayoutManager or GridLayoutManager), or implement your own.

Advantages of RecyclerView

The advantages of recyclerview are as follows:
  • Make dynamic views using recyclerview
  • Don't need to make all the child views
  • Less code as compared if you make a group of the same views
  • Set listeners to the child elements in recyclerview.
  • you can make vertical as well as horizontal scroll list of view
  • Choice from 3 types of layout manager
  • Less memory consumption for better performance
  • Can animate items of recyclerview 
These are some advantages but not least.

RecyclerView Layout Manager

If we compare recyclerview with listview then we have 2 extra types of the list to show a view that is grid view and staggered grid view.

So basically we have 3 layout managers to manipulate the layout of recyclerview. These layout managers are as follows:
  1. Linear Layout Manager
  2. Grid Layout Manager
  3. Staggered Grid Layout Manager
Let's see the examples app which uses a different layout manager in their app.

Layout manager Examples

Here I have listed some example apps so that you can identify their layout manager.  

Linear Layout Manager Example

Linear layout manager is very common to use and it can be found almost every app.

Linear layout manager takes the full width of the device to make a single row like structure.

Some apps that use linear layout manager are:

1. Whatsapp recent chat list.

In the below screenshot of Whatsapp, every recent chat takes full length of device to make list type structure.

Whatsapp recent chat screen

2. Youtube Video Feed

See the below screenshot and see how every child takes full-screen width to the recyclerview.

Youtube App home screen

I hope you now understand and now able to identify the linear layout manager next time.

Grid Layout Manager

As the name suggests a grid-like structure in the app. In the linear layout manager where item takes full width but in grid layout manager item can be 2 or more in a row.

Let's see these examples for better understanding.

1. Instagram Profile Screen

In the below example, when you open your profile screen on Instagram you can see your all posts by you. These posts are the best example of the grid layout manager.

Instagram profile screen

2. Youtube Explore Screen

This is a very good example of the grid layout manager. See how the trending category is showing in the grid form.

Youtube App Trending screen

Staggered Grid Layout Manager

Staggered Grid Layout Manager is similar to grid layout but the key difference is that its item's height can be different from each other. Let's see the below image for better understanding.

1. Pinterest Feed

See how every item has a different height and make beautiful grids.

Pinterest feed screen

This is it. I hope you learn something new if so then don't forget to share this article on your Facebook or Whatsapp or anywhere you want. Thank you for reading.

Share this Article 👇

Subscribe to our Newsletter

By subscribing to our newsletter you're agreeing with our T&C.

Popular Posts

Customize rating bar in android

Working with Bottom Navigation bar in Android [Full Guide]

Custom Switch in Android | | Android Tutorial