Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use GridView or RecyclerView?

I need to create a view where products are compared (min 2, max 5). I had two thoughts:

  1. Create a RecyclerView and each column would be a different item. On init I would have to set number of colums. The bad part is that if one item has more text and would go on another line, the whole column would move down, but others won't.
  2. Create a gridView, but I would have to hardcode or create more cases for every amount of products.

enter image description here

Is there any suggestion on how to implement this view in a better way?

like image 541
Filip Luchianenco Avatar asked Oct 30 '22 20:10

Filip Luchianenco


1 Answers

What you need is a GridLayout:

http://developer.android.com/reference/android/widget/GridLayout.html

Here's a useful tutorial:

http://www.techotopia.com/index.php/Working_with_the_Android_GridLayout_in_XML_Layout_Resources

A GridView however is completely unsuitable for your needs. It can only show equal width items that overflow to the next row when the width of the GridView has been filled.

like image 110
whitebrow Avatar answered Nov 09 '22 17:11

whitebrow