android drawable - RecyclerView ItemDecoration -
i trying create itemdecoration drawn divider between recyclerview items left padding.
currently have implementation inside itemdecoration class:
@override public void ondrawover(canvas c, recyclerview parent, recyclerview.state state) { final int left = parent.getpaddingleft(); final int right = parent.getwidth() - parent.getpaddingright(); final recyclerview.layoutmanager lm = parent.getlayoutmanager(); final int childcount = parent.getchildcount(); (int = 0; < childcount; i++) { final view child = parent.getchildat(i); recyclerview.viewholder viewholder = parent.getchildviewholder(child); final int top = lm.getdecoratedbottom(child); final int bottom = top + mdivider.getintrinsicheight(); mdivider.setbounds(left + 40, top, right, bottom); mdivider.draw(c); } }
but seems divider still drawing full width. doing wrong?
i tried setting insetdrawable left insets (from xml), divider, seems not draw @ all.
ps. 40 value hardcoded one, explanatory purpose. mdivider drawable.
you can follow this tutorial or read this answer similar question.
tip:
for add left padding:
@override public void getitemoffsets(rect outrect, view view, recyclerview parent, recyclerview.state state) { outrect.left = 30; }
Comments
Post a Comment