How to properly set elevation value to recyclerview?

I found the answer after a little bit of searching from here. The problem was the transparent background. Elevation works with only non-transparent backgrounds on views. To fix it we should set android:outlineProvider="bounds" on the view and android:clipToPadding="false" on the view's parent.

Hope it helps someone.


Just set below three property in your recyclerview

android:outlineProvider="bounds"
android:background="@null"
android:elevation="2dp"