title: How to add vertical margin around divider between RecyclerView items in Android?
body: <p>This is my custom Item Decoration class: <strong>DividerItemDecorator.kt</strong></p>
  <pre><code>class DividerItemDecorator(private val mDivider: Drawable) : ItemDecoration() {
  
      override fun onDraw(canvas: Canvas, parent: RecyclerView, state: RecyclerView.State) {
          val dividerLeft = parent.paddingLeft
          val dividerRight = parent.width - parent.paddingRight
  
          val childCount = parent.childCount
          for (i in 0..childCount - 2) {
              val child: View = parent.getChildAt(i)
  
              val params = child.layoutParams as RecyclerView.LayoutParams
  
              val dividerTop: Int = child.bottom + params.bottomMargin
              val dividerBottom = dividerTop + mDivider.intrinsicHeight
  
              mDivider.setBounds(dividerLeft, dividerTop, dividerRight, dividerBottom)
              mDivider.draw(canvas)
          }
      }
  }
  </code></pre>
  <p>This is how I add my custom Item Decoration to my recyclerView:</p>
  <pre><code>subNodeBody.addItemDecoration(DividerItemDecorator(ContextCompat.getDrawable(itemView.context,
                  R.drawable.recyclerview_divider)!!))
  subNodeBody.adapter = RolesAdapter(subNode.roles)
  </code></pre>
  <p>This is the divider drawable: <strong>recyclerview_divider.xml</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;shape xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:shape=&quot;rectangle&quot;&gt;
      &lt;solid android:color=&quot;#e7eef3&quot;/&gt;
      &lt;size android:height=&quot;0.7dp&quot;/&gt;
      &lt;size android:width=&quot;80dp&quot;/&gt;
  &lt;/shape&gt;
  </code></pre>
  <p>The divider looks proper between the RecyclerView items. But there's no space above and below it. Is there a way to add custom margins(top, bottom, right and left) around custom dividers?</p>