draw divider on top of item instead of below
passsy opened this issue · 5 comments
From the Material Design Spec
Dividers are placed along the bottom edge of the content tiles, independent of the grid.
The current implementation draws the dividers below the item:
if (mDividerType == DividerType.DRAWABLE) {
- bounds.top = child.getBottom() + params.topMargin + transitionY;
+ // I haven't tested the drawable implementation
+ bounds.top = child.getBottom() + params.topMargin + transitionY - dividerSize;
bounds.bottom = bounds.top + dividerSize;
} else {
- bounds.top = child.getBottom() + params.topMargin + dividerSize / 2 + transitionY;
+ // this one works great
+ bounds.top = child.getBottom() + params.topMargin - dividerSize / 2 + transitionY;
bounds.bottom = bounds.top;
}
and this can be removed because the size does not change
@Override
protected void setItemOffsets(Rect outRect, int position, RecyclerView parent) {
- outRect.set(0, 0, 0, getDividerSize(position, parent));
+ outRect.set(0, 0, 0, 0);
}
This feature should be optional
@passsy
Thanks for letting me know this!!
But the doc also states
Dividers are 1dp thick, with an opacity of either 12% black in light themes or 12% white in dark themes.
So, I feel I should write gist or something instead of adding its feature to this library.
The correct styling of material dividers is easy.
.color(Color.parseColor("#1effffff")) // for dark themes
.color(Color.parseColor("#1e000000")) // for light themes
.sizeResId(R.dimen.dp1) // 1dp
The problem was the correct positioning of the divider which is not possible with the current API. I suggest a property like this for the Builder
triggering the logic above:
.positionInsideItem(true) // default false
yes, u r right. I'll try to implement its feature in next version
Works! Thank you