donkingliang / GroupedRecyclerViewAdapter

GroupedRecyclerViewAdapter可以很方便的实现RecyclerView的分组显示,并且每个组都可以包含组头、组尾和子项;可以方便实现多种Type类型的列表,可以实现如QQ联系人的列表一样的列表展开收起功能,还可以实现头部悬浮吸顶功能等。
Apache License 2.0
1.65k stars 216 forks source link

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

Open lutao2599 opened 3 years ago

lutao2599 commented 3 years ago

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

donkingliang commented 3 years ago

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

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

lutao2599 commented 3 years ago

感谢您的耐心解答,解决了我的问题,但是有点疑问:就是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 commented 3 years ago

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

------------------ 原始邮件 ------------------ 发件人: "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.

donkingliang commented 3 years ago

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

lutao2599 commented 3 years ago

谢谢大佬

------------------ 原始邮件 ------------------ 发件人: "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 commented 3 years ago

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 commented 3 years ago

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

------------------ 原始邮件 ------------------ 发件人: "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.

donkingliang commented 3 years ago

image

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

lutao2599 commented 3 years ago

没在你的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.