Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take CompoundButtons drawables min size into account during measurements #528

Merged

Conversation

AlexBalo
Copy link
Contributor

@AlexBalo AlexBalo commented Jan 6, 2020

CompoundButtons such as Checkboxes, when are allowed to shrink (flexShrink = 1f), during the recalculation can end up being shrunk more than what I would consider their "minimum size" since the negative space is calculated for all FlexItems in the shrinkFlexItems() method.

The image below shows the behavior explained above:

70343552-e0be2300-1857-11ea-93a1-b72d4a5292dc

In this PR I try to prevent these components to get completely shrunk by considering the minimum size of their button drawable. In this way, the drawable size will determine the minimum size of the widget unless a minWidth or minHeight are specified by the user.

Result:

70348737-9f337500-1863-11ea-92ae-1242306c788a

The following approach also works when text is added to the Checkbox. In the image below it is possible to observe how the text of the checkbox is shrunk:

Screenshot 2019-12-31 at 17 21 42

This Gist contains classes that can be used to test the scenario described above.

@thagikura
Copy link
Contributor

Thanks for the PR! LGTM.

@thagikura thagikura merged commit a8c8b6e into google:master Jan 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants