Pinterest style listview or gridview in android [duplicate]

匆匆过客 提交于 2020-01-02 00:50:39

问题


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


回答1:


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!




回答2:


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



来源:https://stackoverflow.com/questions/9897808/pinterest-style-listview-or-gridview-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!