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
I am also facing this type of issue, Use below code to handle margin issue of recyclerview.
ViewGroup.MarginLayoutParams marginLayoutParams=
(ViewGroup.MarginLayoutParams) recyclerView.getLayoutParams();
// here i try to set only top margin, Get dimension from dimension file.
int topMargin = getResources()
.getDimensionPixelSize(R.dimen.top_margin);
marginLayoutParams.setMargins(marginLayoutParams.getMarginStart(),
topMargin, marginLayoutParams.getMarginEnd(), marginLayoutParams.bottomMargin);
recyclerView.setLayoutParams(marginLayoutParams);