Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lutao2599 opened this issue May 7, 2021 · 9 comments
Open

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

lutao2599 opened this issue May 7, 2021 · 9 comments

Comments

@lutao2599
Copy link

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

@donkingliang
Copy link
Owner

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

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

@lutao2599
Copy link
Author

lutao2599 commented May 7, 2021 via email

@lutao2599
Copy link
Author

lutao2599 commented May 7, 2021 via email

@donkingliang
Copy link
Owner

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

@lutao2599
Copy link
Author

lutao2599 commented May 8, 2021 via email

@lutao2599
Copy link
Author

lutao2599 commented May 9, 2021 via email

@lutao2599
Copy link
Author

lutao2599 commented May 9, 2021 via email

@donkingliang
Copy link
Owner

image

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

@lutao2599
Copy link
Author

lutao2599 commented Jun 11, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants