Explorar el Código

Always apply topMargin

Check LayoutParams before applying, set 0 topMargin if margin is not provided to reset margin.
Guy Carmeli hace 6 años
padre
commit
319d9c8662

+ 6
- 2
lib/android/app/src/main/java/com/reactnativenavigation/presentation/OptionsPresenter.java Ver fichero

@@ -58,8 +58,12 @@ public class OptionsPresenter {
58 58
         if (options.layout.backgroundColor.hasValue()) {
59 59
             view.setBackgroundColor(options.layout.backgroundColor.get());
60 60
         }
61
-        if (options.layout.topMargin.hasValue()) {
62
-            ((MarginLayoutParams) view.getLayoutParams()).topMargin = options.layout.topMargin.get();
61
+        applyTopMargin(view, options);
62
+    }
63
+
64
+    private void applyTopMargin(View view, Options options) {
65
+        if (view.getLayoutParams() instanceof MarginLayoutParams) {
66
+            ((MarginLayoutParams) view.getLayoutParams()).topMargin = options.layout.topMargin.get(0);
63 67
         }
64 68
     }
65 69