Spacing Issue while creating bus layout in recycler view Gridlayout manager

前端 未结 2 1047
一向
一向 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: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.

提交回复
热议问题