Correct way to implement NestedRecyclerview - android

I know this topic has been 'touched' alot of times, but I still haven't found the correct way of implementing recyclerview/s inside recyclerview.
My goal is to have a single vertical recyclerview as parent and multiple horizontal recyclerviews inside of it.
I found an implementation to this within this post answer:
How do I layout nested RecyclerViews, while remaining performant?
What it suggests is, inside parent recyclerview onBindVH() method call
holder.setAdapter(childAdapter).
Is this correct way? I think, this is not the best solution performance wise. Is there better solution to implement nested recyclerviews (explanations are welcome)?

Related

Multiple recyclerviews (gridlayout and horizontal linearlayout) inside one view

I am trying to achive this:
First I tried by putting all my recyclerviews (with WRAP_CONTENT) inside a nestedscrollview. That worked, but the performance was awful. Then I tried to set a height for my recyclerviews, that was a lot better (especially the first gridlayout and the horizontal linearlayout loaded very fast), but still had the problem with the dynamic "category" part.
Now I am trying to put all my recyclerviews inside a single recyclerview with different viewtypes. Since that is a pretty big deal (I need to refactor a lot of code because I have diveded every area from the screenshot inside a single fragment and now I need to put all that code inside an adapter) I wanted to ask if I can actually expect any gain from this, because in the end its again a "nestedscrollview" (made by myself, but...). Or if there is some other "best practice" way to achive this layout.
Thank you
Edit:
As expected this didnt do the trick neither. When just the two first recyclerviews are added as viewtype it scrolls and loads smoothly. But as as soon as I try to add the category items (below the category), I notice a lag and especially when selecting multiple categories and scrolling fast up, there is noticable lag. I guess I will have to change my layout and move the category selection part inside a separate view, just need to come up with a user friendly solution. But its acutally quite dissapointing that, in my opinion such trivial task, laying out multiple tables, is such a pain in the ass on android.
I didn't manage to get it working with standard android stuff.
Now I am using epoxy from airbnb ,and I have converted all my views from nestedscrollview to the epoxy recyclerview. Its a great library, and airbnb use it too for all their views.
Nevertheless it's sad that the android dev team doesn't address this problem and provide a solution besides the info "don't nest multiple scrollviews(recyclerviews) that scroll into the same direction".
You can use Recyclerview in recyclerview.
https://irpdevelop.wordpress.com/2016/02/10/horizontal-recyclerview-inside-a-vertical-recyclerview/
And make sure to use multiple view types.

How can I nest a listviews with recycleviews?

Trying to do something like this, I attempted with a RecycleView nested with a listview. If it`s not possible, can you suggest me a more suitable UI element to get to the design?
It is best to use ViewTypes for this problem. Multiple listviews wil result in scrolling issues. Define a viewtype for different views.
Or Expandable ListView could be an option as well.

Why the ListView collapse when put in a ScrollView

I have read the all the answers here:How can I put a ListView into a ScrollView without it collapsing?But it seems no one cares why the ListView get collapsed when put in a ScrollView.I think something happens to the onMeasure() method but I'm not sure of it.So,does anyone have any idea?
Your aproach is not very good. As you did't describe your situation, i can't say exactly what you need. But anyway i will suggest to use Headers and footers instead of puttings scrollable listView in ScrollView. But if you need that anyway, i suggest to use RecyclerView and NestedScrollView instead, as it handles a lot of scrolling issues.
RecyclerView
NestedScrollView
Android doesn't support putting scrollable UI component as a child to other scrolable UI component. Since ListView is scrollable by default, that might be the problem. Hence, all the suggestions not to use ListView as a child to ScrollView

Can HorizontalView And ScrollView Hold Fragments?

I just would like to ask if these Layouts can hold fragment/multiple fragments. I base this on google play store.
Sorry for bad logic.
Yes, scroll views can hold multiple fragments.
However, managing the fragment stack gets tricky.
Because fragmentManager/ChildFragmentManager will only maintain stack for one container, if I am not wrong.
As long as you don't add them dynamically in run time,it is easy.
i.e. if the fragments are described in the scroll view from xml layout and you don't perform fragment transactions, you are all good.
I have dealt with the same issue, and cost me a lot of trouble but I did implement it. However, if you end up with such a requirement, you might be doing something wrong give other solutions a go and see if you can avoid this requirement.
NOTE : I don't think Google play uses fragments in Scroll Views.
What I see them do is have RecyclerViews within recycler views, if this is what you are talking about
i.e. There are Horizontal RecyclerViews within Vertical RecyclerViews.
In case you are not aware, RecyclerViews are the new version of listViews, they are more powerful and perform way better.
I suggest you don't use listViews, but use RecyclerViews instead.

Implementing listview with scrollable views and view caching

I'm on a research to design a ListView with horizontal scroll of views - something like in the facebook app.
I also need to implement a caching for the horizontally scrollable views.
Some of the options I can think of are:
Horizontal scroll view items.
A ViewPager which I understand is not quite good for this task.
What would be my way to go on this?
I've read some StackOverflow questions and am still researching but none of what I read so far also implement caching for the scrolled horizontal views.
Just use two RecyclerViews which are nested. The backing data is a two dimensional array as the layout is two-dimensional. The outer RecyclerView passes the data for the inner RecyclerView when the onBindViewHolder of the adapter is called. Additionally you may also use different layouts or ViewHolder respectively if the inner view consists only of a single item and does not require horizontal scrolling.
Some references about implementing RecyclerViews
Here: http://www.bignerdranch.com/blog/recyclerview-part-1-fundamentals-for-listview-experts/
Here: https://developer.android.com/reference/android/support/v7/widget/RecyclerView.html
and here: https://developer.android.com/training/material/lists-cards.html
This will help you. You can use caching while scrolling. For example if you load images with horizontal scroll bar, you could use picasso library for catching and loading images.
Dont think big we have some library that will do what you want below listed some of them
https://github.com/sephiroth74/HorizontalVariableListView
https://github.com/EmirWeb/parchment
https://github.com/MeetMe/Android-HorizontalListView
any one this link will help you i belive
https://guides.codepath.com/android/Implementing-a-Horizontal-ListView-Guide
https://www.airpair.com/android/horizontal-image-galleries-android-studio

Categories

Resources