0

Hi I just watch the last video of Android Design in Action: Collections and I would like how do you approach the following view:

enter image description here

The first thing that I though was use a GridView, but how do you achieve the first item fill two items size?

The other solution that I think is use a normal ListView, but in each row return two items view. And for the first row return a single item.

What do you think about these two approach? There are a better options?

UPDATE:

I want to inflate the collection dynamically from a Cursor or a List.

icastell
  • 3,495
  • 1
  • 19
  • 27

3 Answers3

2

Check out the link..

http://www.androidviews.net/2013/01/pinterest-like-adapterview/

in that link have Staggeredgridview example with source code try that..

https://github.com/maurycyw/StaggeredGridViewDemo

Hariharan
  • 24,741
  • 6
  • 50
  • 54
  • Is not the same scenario, because in StaggeredGridView the height is variable, but I want the width variable – icastell Oct 09 '13 at 08:07
0

Not exactly the same scenario, but you may find this post useful.-

Create gridlayout.

Community
  • 1
  • 1
ssantos
  • 16,001
  • 7
  • 50
  • 70
  • Is more less the same scenario, but I fill the items from a Cursor so using LinearLayout is not a good option in terms of performance. – icastell Oct 09 '13 at 08:02
0

Let me help you my friend. Use the following library https://github.com/Utopia-Developers/StaggeredGridView Its an implementation of StaggeredGridView that allows you to set column span on each view in the getView() method of your adapter.Implementation of the StaggeredGridView from Utopia developers

  • You don't help so much – Pedro Paulo Amorim Jul 23 '14 at 04:22
  • Well StaggeredGridView library was never intended for this task although you may achieve the desired result by hacking around a bit. However you should look into http://developer.android.com/reference/android/support/v7/widget/RecyclerView.html. Someone may have made a layout manager for this exact requirement. If I find a layout manager for this I will post but you should look into this. – Rajul Dec 20 '14 at 07:47
  • Have a look at this layout manager https://github.com/lucasr/twoway-view/blob/master/layouts/src/main/java/org/lucasr/twowayview/widget/SpannableGridLayoutManager.java You can use it directly with recyclerview or with the entire abstraction library Lucas has built. Read abt it here http://lucasr.org/2014/07/31/the-new-twowayview/ – Rajul Dec 20 '14 at 08:03