I need to set the top margin on a RecyclerView programmatically, but I get this exception:
java.lang.RuntimeException: Unable to resume activity java.lang.Cla
for me, the parent of recyclerview is a constraintLayout,
recyclerview
constraintLayout
val margins = (rv.layoutParams as ConstraintLayout.LayoutParams).apply { leftMargin = 0 rightMargin = 0 } rv.layoutParams = margins
or it will get cast error, viewGroup.LayoutParams can't be cast to COnstarintLayout.LayoutParams