瀏覽代碼

Fix rn 0.50 repeated calls to onMeasure. (#2261)

Chaitanya Bhagvan 7 年之前
父節點
當前提交
0ea0a7f5f6
共有 1 個文件被更改,包括 7 次插入3 次删除
  1. 7
    3
      android/app/src/main/java/com/reactnativenavigation/views/ContentView.java

+ 7
- 3
android/app/src/main/java/com/reactnativenavigation/views/ContentView.java 查看文件

@@ -66,9 +66,13 @@ public class ContentView extends ReactRootView {
66 66
 
67 67
     @Override
68 68
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
69
-        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
70
-        int measuredHeight = viewMeasurer.getMeasuredHeight(heightMeasureSpec);
71
-        setMeasuredDimension(viewMeasurer.getMeasuredWidth(widthMeasureSpec), measuredHeight);
69
+        int widthSpec = MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.AT_MOST);
70
+        int heightSpec = MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(heightMeasureSpec), MeasureSpec.AT_MOST);
71
+
72
+        super.onMeasure(widthSpec, heightSpec);
73
+
74
+        int measuredHeight = viewMeasurer.getMeasuredHeight(heightSpec);
75
+        setMeasuredDimension(viewMeasurer.getMeasuredWidth(widthSpec), measuredHeight);
72 76
     }
73 77
 
74 78
     @Override