1

This is the code for setting the decoration :-

recyclerView.addItemDecoration(new DividerItemDecoration(recyclerView.getContext(), DividerItemDecoration.HORIZONTAL));

This is the xml :-

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <size android:height="1dp" />
    <solid android:color="@android:color/black" />
</shape>

I have tried setting the drawable using DividerItemDecoration.setDrawable(Drawable drawable) and setting the android:listDivider item in my theme to point to the xml.

I have also tried setting the width to 1dp. Absolutely nothing works.

Any help is appreciated, thanks.

Mihir Kandoi
  • 101
  • 1
  • 10

1 Answers1

6

If the orientation of your RecyclerView is default(vertical), then you should use DividerItemDecoration.VERTICAL instead.

I've just tried creating a RecyclerView with a default DividerItemDecoration and your xml resource, and everything worked

enter image description here

Stanislav Shamilov
  • 1,746
  • 11
  • 20
  • 1
    That did it! I mistook the orientation parameter to be the orientation I want the line to be and not the RecyclerView orientation as it should be. Thanks a ton :) – Mihir Kandoi Feb 19 '19 at 15:16