Spacing Issue while creating bus layout in recycler view Gridlayout manager

前端 未结 2 1043
一向
一向 2021-02-13 02:19

I\'m using recycler view with GirdLayout Manager for creating bus layout

my problem is with spacing I\'m populating data according to row column

This is how I\

相关标签:
2条回答
  • 2021-02-13 02:53

    I suggest implementing your recycler view item layout as a TableLayout or a GridLayout, they provide more flexibility in defining row/column spans.

    Some useful links:

    http://android-pro.blogspot.com.eg/2010/02/table-layout.html https://developer.android.com/guide/topics/ui/layout/grid.html

    0 讨论(0)
  • 2021-02-13 02:58

    The problem, of course, arises from the fact that your elements don't have the same height. You need to assign different row spans to the elements. I would suggest assigning the taller elements (the ones on the left) a row span of 2 and 1 for the smaller ones.

    I think you could do it with a trick like setting your grid layout manager to have a horizontal orientation and use GridLayoutManager.setSpanSizeLookup(..) to control the span (since yours is horizontal now, the span would act on rows). This would require you to probably rework the logic of getting your elements from the backing array. The alternative would be I am afraid (as far as I know) to implement your own custom layout manager.

    0 讨论(0)
提交回复
热议问题