Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google play store like interface using recycler view

My assignment is to create an interface much same like Google Play Store.There will a Category name followed by 3 or 4 cards (horizontal) followed by More button. Then again next category.

I already had implemented this using nesting the horizontal listview inside Vertical listview.

I know, I can achieve this by using the Recycler view with LinearLayoutManager with horizontal orientation. Using this I'll be having one only row.

My question is how do I add 2nd, 3rd row to this? Should I use again nested Recycler view? Are there some better options?

like image 667
Rahul Chaurasia Avatar asked Feb 13 '15 05:02

Rahul Chaurasia


People also ask

What is the use of recycler view?

RecyclerView makes it easy to efficiently display large sets of data. You supply the data and define how each item looks, and the RecyclerView library dynamically creates the elements when they're needed. As the name implies, RecyclerView recycles those individual elements.

What advantages does RecyclerView have for Android Apps?

The major advantage of the usage of RecyclerView is the performance when loading list items in the list to the view. RecyclerView prepares the view behind and ahead beyond the visible entries. It gives significant performance when you need to fetch the bitmap image in your list from a background task.

Should I always use recycler view?

you should use recyclerview because it offers more control than listview. It is litte bit complex but you get there then your life will be super easy whenever you are dealing with list kind of thing.


2 Answers

Dont use nested listviews (you cant scroll horizontally in play store).

Consider the following options:

  1. You can use a simple LinearLayoutManager and make different view types. For the with 3 cards horizontally use a GridLayout or LinearLayout with same weights. The problem here is, that you have to consider the indexes of your underlying data list used in the adapter
  2. Write your own LayoutManager for RecyclerView
  3. Use TwoWay View which is based on RecyclerView and offers a Spannable Grid Layout manager, which seems to be what you are looking for.
like image 190
sockeqwe Avatar answered Oct 13 '22 19:10

sockeqwe


If you inspect the layout of the Google Play app, they do not use a listview/recyclerview for the horizontal cards. I'm pretty sure that is just a linearlayout (horizontal) within a vertical listview / recyclerview.

If you insist on using a horizontal recyclerview for each row, then having a nested recyclerview would be your best option. You can specify a RecycledViewPool so that all the nested recyclerviews share the same pool instead of creating their own.

like image 43
Alex Yau Avatar answered Oct 13 '22 20:10

Alex Yau