how to remove divider between items of Recyclerview in android
First define your RecyclerView :
RecyclerView recycle =(RecyclerView) findViewById(R.id.recyclerView);
and in your activity use this method:
recycle.addItemDecoration(new DividerItemDecoration(context, 0));
Dont use below line of code in your code, its solve the iisue
groceryRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), LinearLayoutManager.HORIZONTAL));
or
recycle.addItemDecoration(new DividerItemDecoration(context, 0));
For some reason the other answers didn't work for me but this workaround did:
for (int i = 0; i < recyclerView.getItemDecorationCount(); i++) {
if (recyclerView.getItemDecorationAt(i) instanceof DividerItemDecoration)
recyclerView.removeItemDecorationAt(i);
}
You can use DividerItemDecoration
class and override its onDraw
method to do nothing like so:
mRecyclerView.addItemDecoration(new DividerItemDecoration(mContext, LinearLayoutManager.VERTICAL) {
@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
// Do not draw the divider
}
});