I really don't know how to describe my problem, but here is an image to show what am talking aboutImage
So judging from the image, the horizontal view with months is a recyclerview with the Layoutmanager set in horizontal, so when someone is scrolling through the months it continuously fetches the correct information/filters based on the month at the middle but do not know how to implement
You can implement those months using a view pager, and then implement a fragment for each month. Each fragment will have a recycler view and fragment will fetch the data and feed it into recycler view.
You can refer to this link for an example https://www.journaldev.com/12958/android-tablayout-viewpager
Related
I have been working on recycler view animations and I stumbled upon a great app (Relay) animation example (video link below) which I have been trying to replicate.
I want to animate each layout item simultaneously inside the recycler view but am not able to figure out the approach for this.
Should I create a custom LayoutManager that animates the views whenever the item layout is changed or use RecyclerView.ItemAnimator is there some better approach to achieve something similar?
https://imgur.com/a/GsM8kO5
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?
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
I was designing a profile page for my app in android Studio with recycler view(Vertical), where each row has its own layout and I load it using the Recycler view adaptor...The 3rd and 4th row of my recycler view are again another recycler view(Horizontal) and they displaying images using another adaptor. My problem is while I am scrolling my activity the 3rd and 4th row slow down the scrolling speed. How can I fix it?
Your problem does not have to be with the adapters, there has to be with the amount of information that the recycler is going to process.
This link can help you.
https://www.reddit.com/r/androiddev/comments/2p99lw/recyclerview_scrollbar_with_lots_of_items_very/
I am trying to create a specific type of recycler view with following requirements:
1) RecyclerView that would show one item per screen (1 row will take the size of screen).
2) When I scroll the recyclerview it should stop scrolling as soon as the next item is visible. (Captures the whole screen).
Please tell me if that is possible or not.
Do you have to use RecyclerView?
Probably you can do that with View Pager.
https://stackoverflow.com/a/22797619