diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java index 964152d93df5b8..870545bc5f451d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java @@ -407,6 +407,13 @@ public static long measureText( } } + // Android 11+ introduces changes in text width calculation which leads to cases + // where the container is measured smaller than text. Math.ceil prevents it + // See T136756103 for investigation + if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.Q) { + calculatedWidth = (float) Math.ceil(calculatedWidth); + } + float calculatedHeight = height; if (heightYogaMeasureMode != YogaMeasureMode.EXACTLY) { calculatedHeight = layout.getLineBottom(calculatedLineCount - 1); diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java index e2a8c05f2f0a9a..9ff17c4359fbe1 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java @@ -427,6 +427,13 @@ public static long measureText( } } + // Android 11+ introduces changes in text width calculation which leads to cases + // where the container is measured smaller than text. Math.ceil prevents it + // See T136756103 for investigation + if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.Q) { + calculatedWidth = (float) Math.ceil(calculatedWidth); + } + float calculatedHeight = height; if (heightYogaMeasureMode != YogaMeasureMode.EXACTLY) { calculatedHeight = layout.getLineBottom(calculatedLineCount - 1);