Horizontal scrolling in android gridview

后端 未结 6 1368
闹比i
闹比i 2021-01-04 22:40

I have a grid view in my application and i need to scroll it horizontally.I have tried changing the gridview to gallery.But then only one row is available,but i need differe

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-04 23:11

    I think your best bet is to use a Gallery and implement an adapter that provides a multirow view in its getView method. See Hello Gallery and look at the ImageAdapter implementation within.

    Instead of the ImageView that getView returns in that example, you can, for example, inflate your own custom layout, for example a LinearLayout with vertical orientation.

    You might consider a TableLayout inside a HorizontalScrollView, but the disadvantage there is that everything will be in memory at once, making it difficult to scale to lots of items. The Gallery recycles Views and offers some resource advantages.

提交回复
热议问题