Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
Updated 29 May 2019
RecyclerView is a flexible view for providing a limited window into a large data set. RecyclerView is an evolutionary version of Listview — one of the most important widgets used in Android development. Android apps using Listview for implementing newsfeed or contact lists will likely face performance issues or unnecessary lags when the user scrolls the view fast. But RecyclerView has improved performance, and it provides a fluid scroll experience for the user.
I will give you the information and important rules you should follow and what you should never do when working with RecyclerView:
1. Replace a complex layout (nested views, RelativeLayout) with the new optimized ConstraintLayout.
ConstraintLayout is to optimize and flatten the view hierarchy of your layouts by applying some rules to each view to avoid nesting.
2. If possible, make all elements of the RecyclerView with the same height. And add:
3. Use the default RecyclerView drawing cache methods and tweak them according to your case. You don’t need a third party library to do so:
4. If you use many images, make sure their size and compression are optimal. Scaling images may also affect performance. There are two sides to the problem – the source image used and the decoded Bitmap.
5. Make sure onBindViewHolder() is as cheap as possible. You can set OnClickListener once in onCreateViewHolder() and call through an interface a listener outside of the Adapter, passing the clicked item. This way you don’t create extra objects all the time. Also check flags and states, before making any changes to the view here.
6. When data gets changed, try to update only the affected items. For example instead of invalidating the whole data set with notifyDataSetChanged(), when adding/loading more items, just use:
Rely on notifyDataSetChanged() as a last resort.
But if you need to use it, maintain your items with unique ids:
I hope this blog will help you to optimize the recycleview in your application.
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
Name
Email
Subject
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.