admin管理员组文章数量:1402407
I set the line height of the text to 20
but when I render the text and try to get the line height from onTextLayout
it find it equal to 20.190475463867188
(it changes depending on the device) .. is this the expected behavior? in iOS the line is exactly equal to 20
.
This is the snack demo: /@abdel.moun/text-line-height
I set the line height of the text to 20
but when I render the text and try to get the line height from onTextLayout
it find it equal to 20.190475463867188
(it changes depending on the device) .. is this the expected behavior? in iOS the line is exactly equal to 20
.
This is the snack demo: https://snack.expo.dev/@abdel.moun/text-line-height
Share Improve this question asked Mar 21 at 18:20 lawaybenlawayben 712 silver badges9 bronze badges1 Answer
Reset to default 0When you set line height to 20
but get 20.190475463867188
on Android (while iOS returns exactly 20), this is normal behavior due to fundamental platform differences:
iOS preserves exact line height values, while Android applies additional font metrics adjustments based on the device's density scaling factor. Android converts your specified values into device-independent pixels (dp) to maintain consistent text appearance across varied screen densities including but not limited to the foldable phones, watches, tablets. This slight variance won't affect visual consistency and requires no correction on your end. You can read more about Pixel Density on Android on the Material Design website.
本文标签: react nativeText line height is incorrect in AndroidStack Overflow
版权声明:本文标题:react native - Text line height is incorrect in Android - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744339807a2601409.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论