You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched existing issues and confirmed this is not a duplicate
Issues and steps to reproduce
When FlexboxLayout's' width is unconstrained (i.e. the width MeasureSpec mode is UNSPECIFIED), its children views are not measured/laid out correctly, resulting in them being not visible.
This is relatively easy to replicate:
Create a simple layout with a single horizontal RecyclerView
Add one item to the RecyclerView, whose view is a FlexboxLayout such that:
its width and height are both set to wrap_content
it contains a TextView with arbitrary text in it
Run the app and observe that the text is not visible
Expected behavior
The FlexboxLayout child TextView should be visible (i.e. allowed to be the width it wants).
it seems to me that mainSize = Math.min(largestMainSize, widthSize); should only apply when widthMode == View.MeasureSpec.AT_MOST, but I might be missing something. I believe the logic should be instead:
I've tested this change on a local branch and it behaves as expected. If that seems right to you I'm happy to open a PR with this change + tests.
In the current state, having mainSize set to widthSize will cause the flex shrink logic to be applied, which will force the children sizes to be something else than the width they want to/should be. Note that disabling flex shrink result in the expected behaviour and is a temporary workaround.
Issues and steps to reproduce
When
FlexboxLayout
's' width is unconstrained (i.e. the widthMeasureSpec
mode isUNSPECIFIED
), its children views are not measured/laid out correctly, resulting in them being not visible.This is relatively easy to replicate:
RecyclerView
RecyclerView
, whose view is aFlexboxLayout
such that:wrap_content
TextView
with arbitrary text in itExpected behavior
The
FlexboxLayout
childTextView
should be visible (i.e. allowed to be the width it wants).Version of the flexbox library
Notes
It seems the issue was introduced by this change: https://github.com/google/flexbox-layout/pull/521/files.
Looking at the current version of the corresponding code:
it seems to me that
mainSize = Math.min(largestMainSize, widthSize);
should only apply whenwidthMode == View.MeasureSpec.AT_MOST
, but I might be missing something. I believe the logic should be instead:I've tested this change on a local branch and it behaves as expected. If that seems right to you I'm happy to open a PR with this change + tests.
In the current state, having
mainSize
set towidthSize
will cause the flex shrink logic to be applied, which will force the children sizes to be something else than the width they want to/should be. Note that disabling flex shrink result in the expected behaviour and is a temporary workaround.Link to code
Here is a link to as simple project which demonstrates the issue: https://github.com/OlivierGenez/flexbox-layout-unconstrained-width-bug.
The text was updated successfully, but these errors were encountered: