From 88eca648a77cc585b6971162427cc6aa94c70c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1nos=20Sicz-Meszi=C3=A1r?= Date: Mon, 22 Apr 2024 21:10:53 +0200 Subject: [PATCH] Preventing negative child width when shrinking on no wrap. --- .../main/java/com/google/android/flexbox/FlexboxHelper.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/flexbox/src/main/java/com/google/android/flexbox/FlexboxHelper.java b/flexbox/src/main/java/com/google/android/flexbox/FlexboxHelper.java index e271d8f6..55ba03c4 100644 --- a/flexbox/src/main/java/com/google/android/flexbox/FlexboxHelper.java +++ b/flexbox/src/main/java/com/google/android/flexbox/FlexboxHelper.java @@ -1273,6 +1273,10 @@ private void shrinkFlexItems(int widthMeasureSpec, int heightMeasureSpec, FlexLi if (!mChildrenFrozen[index] && flexItem.getFlexShrink() > 0f) { float rawCalculatedWidth = childMeasuredWidth - unitShrink * flexItem.getFlexShrink(); + if (rawCalculatedWidth < 0) { + // Make sure no negative width when shrinking + rawCalculatedWidth = 0; + } if (i == flexLine.mItemCount - 1) { rawCalculatedWidth += accumulatedRoundError; accumulatedRoundError = 0;