mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Implement adjustsFontSizeToFit on Android (#26389)
Summary: This adds support for `adjustsFontSizeToFit` and `minimumFontScale` on Android. The implementation tries to match closely the behaviour on iOS (hardcoded 4px min size for example). It uses a simpler linear algorithm for now, opened to improving it now if it is a deal breaker or in a follow up. See https://twitter.com/janicduplessis/status/1171147709979516929 for a more detailed thread about the implementation ## Changelog [Android] [Added] - Implement `adjustsFontSizeToFit` on Android Pull Request resolved: https://github.com/facebook/react-native/pull/26389 Test Plan: Tested by adding the existing `adjustsFontSizeToFit` example from the iOS text page to android. Also added a case for limiting size by using `maxHeight` instead of `numberOfLines`. Reviewed By: mdvacca Differential Revision: D17285473 Pulled By: JoshuaGross fbshipit-source-id: 43dbdb05e2d6418e9a390d11f921518bfa58e697
This commit is contained in:
1 parent
9f8e4accfa
commit
2c1913f0b3
7 files changed
+280
-86
No files matched your search
@@ -222,6 +222,14 @@ class AdjustingFontSize extends React.Component<
|
||||
this.state.dynamicText}
|
||||
</Text>
|
||||
|
||||
<Text
|
||||
adjustsFontSizeToFit={true}
|
||||
style={{fontSize: 20, marginVertical: 6, maxHeight: 50}}>
|
||||
{'Text limited by height, watch as this reeeeaaaally loooooong teeeeeeext grooooows and then shriiiinks as you add text to me! ioahsdia soady auydoa aoisyd aosdy ' +
|
||||
' ' +
|
||||
this.state.dynamicText}
|
||||
</Text>
|
||||
|
||||
<Text
|
||||
adjustsFontSizeToFit={true}
|
||||
numberOfLines={1}
|
||||
|
||||
Reference in new issue
Block a user