Browse Source

Use margin instead of RelativeLayout rules to align component to BottomTabs

Rules caused excessive CPU usage due to RN issue with global layout listener
and keyboard visibility detection.
Guy Carmeli 6 years ago
parent
commit
d12b501916

+ 1
- 2
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsController.java View File

24
 
24
 
25
 import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
25
 import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
26
 import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
26
 import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
27
-import static android.widget.RelativeLayout.ABOVE;
28
 import static android.widget.RelativeLayout.ALIGN_PARENT_BOTTOM;
27
 import static android.widget.RelativeLayout.ALIGN_PARENT_BOTTOM;
29
 
28
 
30
 public class BottomTabsController extends ParentController implements AHBottomNavigation.OnTabSelectedListener, NavigationOptionsListener {
29
 public class BottomTabsController extends ParentController implements AHBottomNavigation.OnTabSelectedListener, NavigationOptionsListener {
150
         getView().removeView(getCurrentView());
149
         getView().removeView(getCurrentView());
151
         bottomTabs.setCurrentItem(newIndex, false);
150
         bottomTabs.setCurrentItem(newIndex, false);
152
         RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT);
151
         RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT);
153
-        params.addRule(ABOVE, bottomTabs.getId());
152
+        params.bottomMargin = bottomTabs.getHeight();
154
         getView().addView(getCurrentView(), params);
153
         getView().addView(getCurrentView(), params);
155
     }
154
     }
156
 
155