Skip to content

feat: android - measurement improvements - #221

Merged
exploIF merged 8 commits into
mainfrom
@exploif/android-measurement-improvements
Oct 31, 2025
Merged

exploIF merged 8 commits into
mainfrom
@exploif/android-measurement-improvements

Conversation

@exploIF

@exploIF exploIF commented Oct 29, 2025

Copy link
Copy Markdown
Collaborator

Description

In order to provide auto-grow mechanism on Android we use StaticLayout which calculates desired component height based on the text paint, spannable and available width.

Current logic comes with a huge limitation, it does work properly only for single instance of the component (as we store last created component instance directly in the view manager).

In order to solve this limitation, I've implemented an enhanced version of this mechanism:

  • we do not store component instance as a view manager property
  • instead we have a static class, which stores spannable and text paint params for each active component instance
  • stored parameters are associated with component by id which equals to viewTag
  • every time component needs a new measurement, we update those values
  • when Yoga asks for new measurements (via measureContent and measure on the view manager) we retrieve a measurement value from the static class store (called MeasurementStore)
  • additionally measurements are cached, we don't calculate it again if not needed (for example padding of the component changes -> it does not affect content size, we can reuse previous value)

@exploIF
exploIF marked this pull request as ready for review October 31, 2025 12:08
@exploIF
exploIF requested a review from szydlovsky October 31, 2025 12:08
@exploIF
exploIF merged commit a16c4d0 into main Oct 31, 2025
5 checks passed
@exploIF
exploIF deleted the @exploif/android-measurement-improvements branch October 31, 2025 13:15
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