Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pinterest style listview or gridview in android [duplicate]

I am looking to implement pinterest style gridview (see image) and am having difficulty coming up with an approach.

The view needs to have 3 columns (like pinterest) with individual images having constant width but variable height. It should be scrollable. I am also concerned about the issue of being able to recycle views as the number of images can be lot (say 1000s)

I am not sure how to approach this view in android.

Gaurav

Pinterest View

like image 527
rOrlig Avatar asked Mar 27 '12 21:03

rOrlig


2 Answers

I never thought about it until you brought it up, but this is an interesting problem to try an solve. My suggestion would be to fit 3 ListView's into the Activity or Fragment. I assume each one recycles their own View's respectively. This solves your performance pretty easily assuming it is safe to do it. So maybe a horizontal LinearLayout that holds the 3 ListViews. Adding some padding to the middle one would produce the desired effect.

Of course, more thought needs to be put into deciding how the images end up where they are, but that is you to figure out :) Hope this gives you some ideas!

like image 193
Andy Avatar answered Nov 02 '22 04:11

Andy


I would do it this way:

ScrollView
  LinearLayout (horizontal)
    LinearLayout (vertical, layout weight for width)
      [All the content in column 1]
    LinearLayout (vertical, layout weight for width)
      [All the content in column 2]
    LinearLayout (vertical, layout weight for width)
      [All the content in column 3]

Use lazy loading for the pictures if there are thousands

like image 3
AJcodez Avatar answered Nov 02 '22 03:11

AJcodez