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

万能分割线在layoutManager为LinearLayoutManager 如何设置左右边距 #22

Closed
hegaojian opened this issue Jul 6, 2021 · 2 comments

Comments

@hegaojian
Copy link

如题,在设置LinearLayoutManager 后,添加了分割线代码如下

mDataBind.listRecyclerView.vertical().divider {
            orientation = DividerOrientation.VERTICAL
            startVisible = true
            endVisible = true
            setDivider(10,true)
            setMargin(8,8)
        }.adapter = testAdapter

想通过setMargin方法设置左右两边的边距,但是没有效果,想问一下,目前万能分割线是否支持这种需求呢?

@liangjingkanji
Copy link
Owner

liangjingkanji commented Jul 6, 2021

LinearLayoutManager不支持四周全包裹的分割线.

两种解决办法

  1. 使用spanCount为1的GridLayoutManager
  2. 在RecyclerView两侧绘制一个View作为分割线

推荐第一种解决办法, 示例代码如下

binding.rv.grid().divider{
    includeVisible = true
    setDivider(2, true)
    setColor(Color.RED)
    orientation = DividerOrientation.GRID
}.setup {
    addType<DividerModel>(R.layout.item_divider_vertical)
}.models = getData()

@hegaojian
Copy link
Author

明白了,感谢 👍👍👍

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