Help with center divider in GridLayout
See original GitHub issueI’m trying to create a two column layout with dividers between the items, but what I’ve tried doesn’t work.
Here’s how I’m setting up the layout:
mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), COLUMN_COUNT));
Here’s how I’m setting the divider:
mRecyclerView.addItemDecoration(new FlexibleItemDecoration(getActivity())
.withDivider(R.drawable.divider)
.addItemViewType(R.layout.item_category_button,2,1,2,1)
.withEdge(true)
.withDrawOver(true));
With the above code, I see a center line, but it’s white and not the color as specified in the divider drawable. (I grabbed that divider drawable from the sample app.)
I’ve read the wiki and cloned the project so I can work directly with the example app, but I’m unable to create the center divider I need. From what I’m seeing, it appears the divider only applies to the top and bottom, not the left and right.
NOTE: If I use a left and right width of just 1 in the above code, I don’t even see the white center line.
Thanks for your library and I appreciate any help!
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
I created a new ItemDecoration class and replaced the draw method and it worked great!
From reading the Wiki, I thought that’s what the left/right edge settings were for, but I guess they don’t apply to the item decoration.
Anyway, your suggestion worked so I’ll close this issue. Thanks again for the help!
Yes, that creates the button look I need for multiple columns and multiple rows.