Comparing RecyclerView and ListView

Posted By : Manisha Prajapati | 27-Jan-2021

As an Android developer, many of us asked me what’s the difference between ListView and RecyclerView actually I personally wasn't conscious of the differences unless I dig at heart and explored more.


Based on my experience of using both the components, I might wish to place here a few points that could assist your understanding in a better way.
With the arrival of Android Lollipop, the RecyclerView made its way officially. The RecyclerView is substantially more powerful, robust, cost-effective and a serious enhancement over ListView.

 

As per the Android developer site, RecyclerView was introduced with Android 5.0 (Lollipop). Certainly, it is included in the Support Library. Thus, it is a congruent event with Android API Level 7.

 
ListView vs RecyclerView – Key differences
 

1. ViewHolder Pattern -

 

In a ListView, it had been recommended to use the ViewHolder pattern but it had been never a compulsion. just in the case of RecyclerView, this is often mandatory using the RecyclerView.ViewHolder class. this is often one of the main differences between the ListView and therefore the RecyclerView. It makes things a touch more complex in RecyclerView but tons of problems that we faced within the ListView are solved efficiently.

 

2. LayoutManager -

 

This is another massive enhancement delivered to the RecyclerView. during a ListView, the sole sort of view available is that the vertical ListView. there are no official thanks to even implement a horizontal ListView.
Now employing a RecyclerView, we will have a


i) LinearLayoutManager — allows you to specify an orientation, a bit like a traditional LinearLayout,
 

ii) StaggeredLayoutManager —  It supports horizontal & vertical layout as well as an ability to layout children in reverse. It supports Pinterest-like staggered lists,
 

iii) GridLayoutManager — If we want the grids in our lists like the gallery then we need to choose the Grid layout manager
 

And the neatest thing is that we will do these dynamically as we would like.

 

3. Item Animator - 

 

ListViews may not be sufficient to support excellent animations, but the RecyclerView adds an entirely new dimension. As we will look forward to, it’s handling row views animations like list appearance and disappearance, adding or removing particular views then on.

 

By omission, RecyclerView’s list animations are nice and smooth. Of course, we will change that by creating our own ItemAnimator, which is additionally not that easy. to form it easier, we should always extend the SimpleItemAnimator class and implement the methods that we'd like (just add animations to a ViewHolder’s views).

 

To be honest, implementing animations on the ListView was a pain within the ass. Again, we had to work out how we would like to handle them. Nothing nice. I’m glad it’s gone.

 

4. Item Decoration - 

 

Duty of the ItemDecoration may seem pretty simple theoretically – add some decorations for the list row views – but in practice, it’s not easy to implement if we would like to make a custom one. During this case, we should always extend the ItemDecoration class and implement our solution. For example,  there are no dividers between rows by default in the RecyclerView list and it adheres to the fabric Design guidelines. However, if we would like to feature a divider for a few reasons, we will use DividerItemDecoration and add it to the RecyclerView.

 

In case we use the ListView, we've to work out row decorations by ourselves. there's no helper class like ItemDecoration for this widget.

 

5. OnItemTouchListener - 

 

Seizing item clicks on a ListView was simple, because of its AdapterView.OnItemClickListenerinterface. But the RecyclerView gives substantially more capability and authority to its developers by the OnItemTouchListener but it collaborates things for the developer.
In simple words, the RecyclerView is much more custom-built than the ListView and provides tons of control and power to its developers.

 

6. Performance on Loading -

 

RecyclerView prepares a view just ahead and behind the visible entries. This works just great if you're fetching bitmaps in the background. Performance is dramatically faster, especially if you employ RecyclerView.setHasFixedSize. The old ListView is predicated on the premise that there are no thanks to precalculating or cache the dimensions of entries within the list, which causes insane complications when scrolling and performing layout. Takes a short time to urge won't to it, but once you are doing, you’ll never return. 

 

For a more detailed description, you can refer here.

 

Turn To Our SaaS Web And Mobile App Development Services

 

We are a SaaS application development company that provides end-to-end mobile app development services with a focus on cutting-edge technologies. Our development team uses JavaScript tools like Angular, Node, and ReactJS to make it adaptable, responsive, and include rich web applications to address different business prerequisites. We have an experienced team of Full Stack engineers that are skilled at performing both frontend and backend assignments. Our SaaS app development services address your project requirements by developing user-friendly apps that are easy to scale.

About Author

Author Image
Manisha Prajapati

She worked as a Xamarin Developer as well as Bi Developer . She had a good knowledge of C-sharp , Xamarin.forms, Oops, Power Bi, Sqlite, etc. She has ability to work in Harmony with Co-Workers and Eager and willing to add her Knowledge base and skills.

Request for Proposal

Name is required

Comment is required

Sending message..