如何将 React Native Fontsize 设置为 pt?



什么是 React Native FontSize Unit? px 还是 pt? 我想用pt设置字体大小。 我该怎么做?

我知道 1em = 12 pt = 16 px。 但是我必须将字体大小设置为 13pt。 我该怎么做?

主要单元被称为dp(与密度无关的像素(。对于字体,它被称为sp(与比例无关的像素(

从文档中:

React Native 中的所有维度都是无单位的,并且表示与密度无关的像素。

这包括字体大小。这主要是因为不同的手机具有不同的 DPI,并且像 px 这样的单位不会根据每部手机的 DPI 优雅地缩放。

来源:

  • https://facebook.github.io/react-native/docs/height-and-width.html

  • https://developer.android.com/guide/topics/resources/more-resources#Dimension

  • https://material.io/design/layout/understanding-layout.html

最新更新