Repository navigation
Refresh padding and text after a pixel density change (#59049) - #59049
Closed
brunocramos wants to merge 1 commit into
Closed
brunocramos wants to merge 1 commit into
brunocramos wants to merge 1 commit into
Conversation
|
@brunocramos has exported this pull request. If you are a Meta employee, you can view the originating Diff in D124076552. |
Summary: When an Android app handles density changes itself (`density` in `android:configChanges`), its surface is laid out again at the new density, but some mounted views keep sizes from the old one: - Padding and overflow insets are sent to views in pixels, but only when their dp values change, which a density change usually doesn't do. A `TextInput` keeps its old pixel padding, so its text and placeholder can be clipped. - Paragraph state only updates when the text, its attributes or its measured size change, so `Text` keeps the layout it built at the old density and draws at the old size. With the new `fixTextLayoutOnPixelDensityChange` feature flag on, padding and overflow insets are re-sent when the pixel density changes (zero insets are skipped: they are zero pixels at any density), and paragraph state is rebuilt. Both text paths are covered: with `enablePreparedTextLayout`, the paragraph prepares a new layout at the new density (the prepared text cache is keyed by density) and its state now updates when only the density changed; without it, the state records the density too. The flag is off by default. **How to use:** return `true` from your app's feature flag overrides, before React Native starts: ``` override fun fixTextLayoutOnPixelDensityChange(): Boolean = true ``` Changelog: [Internal] Reviewed By: javache Differential Revision: D124076552
brunocramos
force-pushed
the
export-D124076552
branch
from
October 13, 2026 20:10
b48b913 to
6cb1119
Compare
|
This pull request has been merged in d026c0f. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
When an Android app handles density changes itself (
densityinandroid:configChanges), its surface is laid out again at the new density, but some mounted views keep sizes from the old one:TextInputkeeps its old pixel padding, so its text and placeholder can be clipped.Textkeeps the layout it built at the old density and draws at the old size.With the new
fixTextLayoutOnPixelDensityChangefeature flag on, padding and overflow insets are re-sent when the pixel density changes (zero insets are skipped: they are zero pixels at any density), and paragraph state is rebuilt. Both text paths are covered: withenablePreparedTextLayout, the paragraph prepares a new layout at the new density (the prepared text cache is keyed by density) and its state now updates when only the density changed; without it, the state records the density too. The flag is off by default.How to use: return
truefrom your app's feature flag overrides, before React Native starts:Changelog:
[Internal]
Reviewed By: javache
Differential Revision: D124076552