1

I am using a custom divider.

And I add a divider after each itemView.

divider

When I select several elements next to each other, it turns out that the divider is between them. And you can see white space on the left.

divider between items

 public OrderRecyclerViewItemDecoration(Context context, int orientation) : base(context, orientation)
    {
        Drawable = context.CompatGetDrawable(ResourceConstant.Drawable.recycler_view_divider);
    }

    public override void OnDraw(Canvas c, RecyclerView parent, RecyclerView.State state)
    {
        var childCount = parent.ChildCount;
        for (int i = 0; i < childCount; i++)
        {
            var child = parent.GetChildAt(i);
            var childPosition = parent.GetChildAdapterPosition(child);
            var viewType = parent.GetAdapter()!.GetItemViewType(childPosition);

            if (!NeedDivider(viewType))
                continue;
            
            var orderItemLeft = child.FindViewById<View>(Resource.Id.order_item_left);
            int left = orderItemLeft?.Right ?? child.Left;
            
            Drawable.Bounds = new(left, child.Bottom, child.Right, child.Bottom + Drawable.IntrinsicHeight);
            Drawable.Draw(c);
        }
    }

How can I make a divider inside each item?

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.