The ItemDecoration is displayed over the RecyclerView, not below it

1k Views Asked by At

I am creating a RecyclerView with hard-coded content, and the elements are displayed correctly, but I want to put an Item Decoration, but it is displayed on the RecyclerView, I want it to be displayed below.

I tried creating a custom LinePagerIndicatorDecoration class by extending it, and changing the height of the Indicator but it didn't work.

recyclerNew?.apply {
                layoutManager = LinearLayoutManager(_context, RecyclerView.HORIZONTAL, false)
                addItemDecoration(LinePagerIndicatorDecoration(_context))
                adapter = newsAdapter
                setHasFixedSize(true)
                invalidate()
            }

The ItemDecoration is shown above the recycler, and I wanti it below.

Someone can help me?

enter image description here

1

There are 1 best solutions below

0
On

You can use ItemDecoration like this:

// To give the border line in the recyclerview
RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration( getApplicationContext(), DividerItemDecoration.VERTICAL ); 
recyclerView.addItemDecoration( itemDecoration );