GroupedRecyclerViewAdapter icon indicating copy to clipboard operation
GroupedRecyclerViewAdapter copied to clipboard

如何实现线性布局和网格布局同时存在

Open lutao2599 opened this issue 4 years ago • 9 comments

如何实现首页上面是线性布局,下面是网格布局

lutao2599 avatar May 07 '21 09:05 lutao2599

使用GroupedGridLayoutManager,复写getChildSpanSize方法。当某个组想要线性布局时,getChildSpanSize就返回spanCount,item就会占满一行。

可参考我的demo中的Grid2Activity页面。

donkingliang avatar May 07 '21 09:05 donkingliang

感谢您的耐心解答,解决了我的问题,但是有点疑问:就是groupPosition=0要一行显示,等于1的时候要使用网格,但是要反过来赋值才达到我想要的效果,请问怎么回事?

------------------ 原始邮件 ------------------ 发件人: "donkingliang/GroupedRecyclerViewAdapter" @.>; 发送时间: 2021年5月7日(星期五) 下午5:41 @.>; @.@.>; 主题: Re: [donkingliang/GroupedRecyclerViewAdapter] 如何实现线性布局和网格布局同时存在 (#73)

使用GroupedGridLayoutManager,复写getChildSpanSize方法。当某个组想要线性布局时,getChildSpanSize就返回spanCount,item就会占满一行。

可参考我的demo中的Grid2Activity页面。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

lutao2599 avatar May 07 '21 10:05 lutao2599

请问怎么修改网格布局之间的间距

------------------ 原始邮件 ------------------ 发件人: "donkingliang/GroupedRecyclerViewAdapter" @.>; 发送时间: 2021年5月7日(星期五) 下午5:41 @.>; @.@.>; 主题: Re: [donkingliang/GroupedRecyclerViewAdapter] 如何实现线性布局和网格布局同时存在 (#73)

使用GroupedGridLayoutManager,复写getChildSpanSize方法。当某个组想要线性布局时,getChildSpanSize就返回spanCount,item就会占满一行。

可参考我的demo中的Grid2Activity页面。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

lutao2599 avatar May 07 '21 10:05 lutao2599

1、给item布局的margin设置间隔。 2、参考我demo中的自定义CustomGridItemDecoration。需要间隔的item,对应的getxxxSize方法返回间隔大小,不需要则返回0。Drawable可以返回null。

donkingliang avatar May 08 '21 01:05 donkingliang

谢谢大佬

------------------ 原始邮件 ------------------ 发件人: "donkingliang/GroupedRecyclerViewAdapter" @.>; 发送时间: 2021年5月8日(星期六) 上午9:54 @.>; @.@.>; 主题: Re: [donkingliang/GroupedRecyclerViewAdapter] 如何实现线性布局和网格布局同时存在 (#73)

1、给item布局的margin设置间隔。 2、参考我demo中的自定义CustomGridItemDecoration。需要间隔的item,对应的getxxxSize方法返回间隔大小,不需要则返回0。Drawable可以返回null。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

lutao2599 avatar May 08 '21 01:05 lutao2599

demo中没有这个类

------------------ 原始邮件 ------------------ 发件人: "donkingliang/GroupedRecyclerViewAdapter" @.>; 发送时间: 2021年5月8日(星期六) 上午9:54 @.>; @.@.>; 主题: Re: [donkingliang/GroupedRecyclerViewAdapter] 如何实现线性布局和网格布局同时存在 (#73)

1、给item布局的margin设置间隔。 2、参考我demo中的自定义CustomGridItemDecoration。需要间隔的item,对应的getxxxSize方法返回间隔大小,不需要则返回0。Drawable可以返回null。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

lutao2599 avatar May 09 '21 05:05 lutao2599

我是要缩小网格布局之间的间距,该怎么操作呢

------------------ 原始邮件 ------------------ 发件人: "donkingliang/GroupedRecyclerViewAdapter" @.>; 发送时间: 2021年5月8日(星期六) 上午9:54 @.>; @.@.>; 主题: Re: [donkingliang/GroupedRecyclerViewAdapter] 如何实现线性布局和网格布局同时存在 (#73)

1、给item布局的margin设置间隔。 2、参考我demo中的自定义CustomGridItemDecoration。需要间隔的item,对应的getxxxSize方法返回间隔大小,不需要则返回0。Drawable可以返回null。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

lutao2599 avatar May 09 '21 06:05 lutao2599

image

间距大小是可以自己设置的,getxxxSize方法返回0,就是没有间隔。

donkingliang avatar May 10 '21 01:05 donkingliang

没在你的demo中找到这个类

------------------ 原始邮件 ------------------ 发件人: "donkingliang/GroupedRecyclerViewAdapter" @.>; 发送时间: 2021年5月8日(星期六) 上午9:54 @.>; @.@.>; 主题: Re: [donkingliang/GroupedRecyclerViewAdapter] 如何实现线性布局和网格布局同时存在 (#73)

1、给item布局的margin设置间隔。 2、参考我demo中的自定义CustomGridItemDecoration。需要间隔的item,对应的getxxxSize方法返回间隔大小,不需要则返回0。Drawable可以返回null。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

lutao2599 avatar Jun 11 '21 06:06 lutao2599