My question is why do wrap recycler view into nested scroll view
Does it relate to smooth scroll of recycler view
Actually i am creating app which fetch 2 images and the scroll of recycler view in that is very slow so should i wrap it into nested scroll view for smooth flow or compress images and store them
I am a bit confused on this topic ?
Wrapping Recycler view in scroll view is like a two sided blade. You should be careful about using it.
because when you use it, the recycler view will loose its advantage of recycling unneeded rows so at the same time you will have references to all those view, so if you have rows with many graphical item it will make problem for slow devices.
If you see putting the recycler view inside another nested scrollview solved your speed problem, It means you do a mess in the adapter of recycler view.
Do not do any heavy process in adapters and onBindViewHolder
Related
I am using recycler view with linear layout manager, based on some logic I am hiding/showing a view inside recycler view item.
Issue Problem occurs when I scroll, I can see some gaps in between recycler view item, which are random when scroll. If I hide the view always , then there is no issue, but I need to show and hide based on some logic and when implemented the gaps are coming as well.
Assumption One thing I am sure of is that the issue is there because of hiding/showing a view.
How can I implement this kind of UI, where we have two recyclerViews. One scrolls horizontally and the second one vertically. when the second one scrolls first one also scrolls top together.
I tried to implement using NestedScrollView, but I had to make second recyclerView height wrap content which causes recyclerView not recycle.
The second way that I tried was having one recyclerView. And adding horizontal recyclerview as a header. The problem was to save header recyclerview scroll state when navigation. And there had been crashes when loading next page (paging 3) in header recyclerView.
The question is: Is there any optimal solution for this kind of ui?
In cases, Like this, you don't have to use 2 RecyclerView and you also have to avoid using RecyclerView insideScrollView. instead of this you have to use one vertical RecyclerView with multitype view Adapter.
in this way, you are going to have 2 different ViewHolder one of them is a horizontal recyclerView (your top item) and the other one is your other items.
for learning multitype adapter you can see this:
How to create RecyclerView with multiple view types
and for a horizontal recyclerView inside a vertical RecyclerView you can see this :
https://medium.com/#ashishkudale/android-list-inside-list-using-recyclerview-73cff2c4ea95
you have to combine these 2.
I could not understand the meaning of "header" where you said "adding horizontal recyclerview as a header" but if you did what I told and the problem is the state of inner Horizontal recyclerView, I think probably you are calling setAdapter method of horizontal RecyclerView in OnBind() method of your vertical recycler view, it is a common mistake that I have seen in many tutorials.
if you have done this mistake , try to call setAdapter of your inner recyclerView in the constructor of its viewHolder and just update the list using yourHorizontalAdapter.notifyDataSetChanged() in onBind() method of VerticalRecylerView,
and if its not the case and your recyclerView is completely destroying see this link :How to save RecyclerView's scroll position using RecyclerView.State?
I have a RecyclerView adapter and in each view holder I have nested view group (TagGroup https://github.com/2dxgujun/AndroidTagGroup)
The performance is horrible while scrolling with these nested ViewGroups
My adapter even uses sethasstableids(true) which speed up scrolling performance slightly
My question: Is there any way to stop certain parts of onBingViewHolder() code while scrolling i.e. the section where the view group is populated
I know so that some image loading libraries have way to stop loading image while scrolling
below you can see the TagGroup (ViewGroup) in each view holder
https://drive.google.com/file/d/0B-fCQa73GiDYZDgtMXJoR2k2M045Nm10dDRRLXA4RW9YaGZB/view?usp=sharing
I have recycler view with different type of cards inside it with lots of images and nested recycler view for every card. While scrolling recycler view I am getting lot of jerk can someone help me on this.
I'm developing an app that has an UI pretty similar to Play Store. It is organized as a multiple panels one above another. First it has a panel containing a photo. Under that it has another panel containing some text and a custom background color. Under that it has another photo and finally it has a Linear Layout with vertical orientation containing a pretty long list of little views filled dynamically at runtime. I have all this inside a Scroll View, naturally.
The problem? That dynamic fill of the linear layout takes a long processor time and makes my app unresponsive during those inner views inflation. So I thought to replace the linear layout by a Recycler View. And the performance is awesome!
So? Well... Not everything is so awesome. I can't scroll the Recycler View because it's inside the Scroll View. And if I remove the Scroll View then I can't scroll the entire view (some things doesn't fit on the screen).
What's the best approach for fixing this?
It's not recommended to use a RecyclerView or ListView inside of a ScrollView precisely due to the double scrolling issues. RecyclerView is very robust and is prepared to receive headers, footers, etc. I see no reason why the entire layout could not be inside of a RecyclerView instead of a ScrollView
The ViewHolder implementation can include logic to inflate different layouts depending on what section should be next.
Pseudocode:
i.e.
if(currentAdapterItem == sectionA){
useLayoutA();
} else{
useLayoutB();
}
Just use a NestedScrollView instead of a normal ScrollView. It handles the nested scrolling quite well.