Please see below image:
How can i insert multiple card View inside a Recycler View.
or any other way to achieve this.
Using of Recycler view is must.
A nested RecyclerView is an implementation of a RecyclerView within a RecyclerView. An example of such a layout can be seen in a variety of apps such as the Play store where the outer (parent) RecyclerView is of Vertical orientation whereas the inner (child) RecyclerViews are of horizontal orientations.
RecyclerView does not allocate an item view for every item in your data source. Instead, it allocates only the number of item views that fit on the screen(Viewport) and it reuses those item layouts as the user scrolls.
I think the proper way to achieve the goal as described in the image attached would be to use GridLayoutManager
rather than using a RecyclerView.LayoutManager
or LinearLayoutManager
.
The LayoutManager
we attach on the RecyclerView
decides the number of columns. There are like 3 subclasses.
LinearLayoutManager
GridLayoutmanger
StaggeredGridLayoutmanger
In your activity where you initialize the RecyclerView.LayoutManager
, change
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManger(this);
to
GridLayoutManager mLayoutManager = new GridLayoutManger(this, 2);
2 being the span count of the grid. Each item will be placed in a single span and thus you will have 2 columns in your recycler view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With