![]() In case, we are forced to use notifyDataSetChanged() based on our use-case, we can try the setHasStableIds(true). adapter.notifyItemRemoved(position)Īdapter.notifyItemRangeInserted(start, end) ![]() Whenever we have the use-case of the removal, the updation, the addition of item, use the Notify Item API. We can see the improvement in our RecyclerView by doing so. We should check our onBindViewHolder method and optimize it. Our onBindViewHolder method should do very less work. Problem Solved! Do less in onBindViewHolder method Then, we will be able to set the width and height prior only. So, we should ask our backend developer to send the image size or the aspect ratio, accordingly, we can calculate the required width and height of the ImageView. If we do not set the correct image width and height prior, the UI will flicker during the transition of loading(downloading of image) and setting of the image into the ImageView(actually making it visible when downloading completes). If our image width and height are dynamic(not fixed), and we are getting the imageUrl from the server. If you are curious to know: How The Android Image Loading Library Glide and Fresco Works? Read here. So, always use Image-Loading libraries.ĭelegate all the image-related tasks to these libraries. The best part is that Image-Loading libraries like Glide, Fresco uses this bitmap pool concept. By using the bitmap pool concept, we can avoid it. Let's get started Use Image-Loading LibraryĪs the Garbage Collection(GC) runs on the main thread, one of the reasons for unresponsive UI is the continuous allocation and deallocation of memory, which leads to the very frequent GC run. ![]() Let's see what are the things which we can do to improve the performance of the RecyclerView and hence, we get the smooth scrolling. It leads to bad user experience as it seems that our Android App is laggy. When we implement RecyclerView in our Android Application, sometimes, we face problems like: The RecyclerView items are not scrolling smoothly. ![]() With these optimizations, we can make the RecyclerView scrolling smooth. In this blog, we are going to learn how to optimize the RecyclerView performance in Android. I am Amit Shekhar, writing this article to share about RecyclerView Optimization. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |