diff --git a/app/src/main/java/org/oppia/android/app/databinding/MarginBindingAdapters.java b/app/src/main/java/org/oppia/android/app/databinding/MarginBindingAdapters.java index 69dd1f379c4..9cd9ac3d8b5 100644 --- a/app/src/main/java/org/oppia/android/app/databinding/MarginBindingAdapters.java +++ b/app/src/main/java/org/oppia/android/app/databinding/MarginBindingAdapters.java @@ -15,7 +15,7 @@ public static void setLayoutMarginStart(@NonNull View view, float marginStart) { if (view.getLayoutParams() instanceof MarginLayoutParams) { MarginLayoutParams params = (MarginLayoutParams) view.getLayoutParams(); MarginLayoutParamsCompat.setMarginStart(params, (int) marginStart); - view.requestLayout(); + view.setLayoutParams(params); } } @@ -25,7 +25,7 @@ public static void setLayoutMarginEnd(@NonNull View view, float marginEnd) { if (view.getLayoutParams() instanceof MarginLayoutParams) { MarginLayoutParams params = (MarginLayoutParams) view.getLayoutParams(); MarginLayoutParamsCompat.setMarginEnd(params, (int) marginEnd); - view.requestLayout(); + view.setLayoutParams(params); } } @@ -36,7 +36,6 @@ public static void setLayoutMarginTop(@NonNull View view, float marginTop) { MarginLayoutParams params = (MarginLayoutParams) view.getLayoutParams(); params.topMargin = (int) marginTop; view.setLayoutParams(params); - view.requestLayout(); } } @@ -47,22 +46,6 @@ public static void setLayoutMarginBottom(@NonNull View view, float marginBottom) MarginLayoutParams params = (MarginLayoutParams) view.getLayoutParams(); params.bottomMargin = (int) marginBottom; view.setLayoutParams(params); - view.requestLayout(); - } - } - - /** Used to set a margin for views. */ - @BindingAdapter("app:layoutMargin") - public static void setLayoutMargin(@NonNull View view, float margin) { - if (view.getLayoutParams() instanceof MarginLayoutParams) { - MarginLayoutParams params = (MarginLayoutParams) view.getLayoutParams(); - params.setMargins( - (int) margin, - (int) margin, - (int) margin, - (int) margin - ); - view.requestLayout(); } } }