I've been learning to use the RecyclerView
. My main intention to learn how to use it was that I needed to implement a horizontal list, that is, when turning the device in landscape mode (horizontal) it would appear as follows:
After a lot of searching, I found the detailed way to be able to implement it (how to create the horizontal scrolling of the RecyclerView
, here ), but I ran into another problem. The del item RecyclerView
was larger than the height of the device (in landscape, horizontal), so I need to create a vertical and horizontal scroll at the same time.
I have looked at Android Developer the methods of the LayoutManager class, but my knowledge is not high enough to understand most of the methods that exist, I have also tried to put another horizontal RecyclerView with all the content inside a vertical RecyclerView, but it gives me an error IllegalStateException: RecyclerView has no LayoutManager
that I have found, as a solution, remove all <View.../>
of the XML file, but it does not give any result, and of course, I have searched thousands of Internet pages, but it is seen that nobody has considered this or not it's possible.
To clarify, what I am asking for with this entry is that someone tell me if this is possible and if they have a possible idea of how to implement it (although I don't know if it is possible) and if it is not possible, explain why.
Of course it is possible, what you have to do is what you have investigated, create a
LinearLayoutManager
horizontal that will containRecyclerView
:which are the views that would be recycled Horizontally:
and inside each horizontal element add a
RecyclerView
,which will contain views that would recycle vertically:
I was so angry about all the problems I had with the app that I hadn't thought of the easiest solution.
It turns out that a RecyclerView is made up of two XML files, a main one where the RecyclerView is declared and another with the content of said RecyclerView item.
The simplest and dumbest solution was to wrap the RecyclerView inside a ScrollView. So I will be able to move all the items at the same time vertically thanks to the ScrollView and I will also be able to move the items horizontally thanks to the RecyclerView in horizontal mode.
I leave here the main file of the RecyclerView as a sample:
activity_main.xml