Recycler View Horizontal Android
I've made two recycler views in one layout. I am facing an issue that my horizontal recycler view is shown as vertical view I've uploaded my xml file. The vertical recycler view is
Solution 1:
To make your RecyclerView
horizontal, you need to set it's layoutManager
.
finalGridLayoutManagerlayoutManager=newGridLayoutManager(this, NUM_OF_ROWS, GridLayoutManager.HORIZONTAL, false);
m_recyclerView.setLayoutManager(layoutManager);
Solution 2:
The Orientation is controlled by your layout manager, make sure you have its orientation set to HORIZONTAL, I would recommend using LinearLayoutManager
for this use case.
in Kotlin:
//In your activity / fragmentvallinearLayoutManager= LinearLayoutManager(
context,
LinearLayoutManager.HORIZONTAL,
false
)
yourRecyclerView.layoutManager = linearLayoutManager
Hope it solves your problem :)
Post a Comment for "Recycler View Horizontal Android"