https://kotlinlang.org logo
Title
c

Cyberpunk Keanu

11/17/2019, 3:54 PM
Can someone help me with Recyclerview layouts. What I'm trying to achieve is a Horizontal recyclerview, with a single row, & fit atleast 2 items in the total horizontal screen width. My issue, the item populating in the recyclerview take the width of the whole screen show it is only showing 1 item. If my primary condition wasn't for it to be a Horizontal scroll, I would've just used
recyclerview.layoutManager = GridLayoutManager(context, 2)
But this code by default makes the Grid layout scroll vertically. And if I add
(context, 2, GridLayoutManager.HORIZONTAL, false)
it adds 2 rows instead of 2 items in a row, but it does scroll Horizontal. Help? (P.S. It is important that the solution given scrolls the recyclerview Horizontally 🙏) Edit: A good example of what I'm trying to achieve would be this playstore's implementation of horizontal recyclerview. My items take the whole screen width unlike shrinking & thus effectively showing 2 items at once
m

Mtsahakis

11/17/2019, 4:22 PM
Maybe try something like this:
recycler.layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
Then set the adapter, and should display all the items passed to your adapter, 2 or more.