我想知道为什么我在react native的文本中会出现这些奇怪的padding.我try 了各种方法来获得一个完美的文本,但似乎没有任何效果.唯一有效的方法是paddingVerticalpaddingHorizontal,但它太粗糙,不可靠.

<Text numberOfLines={1} 
      style={{
            backgroundColor: 'red', 
            lineHeight: 92, 
            textAlign: 'center', 
            textAlignVertical: 'center', 
            padding: 0, 
            margin: 0, 
            fontSize: 92,  
            color: '#2d76ff', 
            fontFamily: 'Roboto-Regular', 
            includeFontPadding: false}}>
      {this.state.documents}
</Text>

Zeplin

enter image description here

Screenshot from my HTC

enter image description here

推荐答案

我偶然发现了这个问题,因为我也经历了同样的问题.文本组件有一个名为includeFontPadding的props .可以将其设置为false以删除额外的填充.

查看React原生文档以供参考:https://facebook.github.io/react-native/docs/text-style-props#includefontpadding

React-native相关问答推荐

如何在react-native 的switch 内显示文本(是/否)

react-native 自定义视图,原生 prop 没有 propType

React 从 babel 6 到 babel 7 的原生升级

React中类似于 React Native 中的 FlatList

React-Native 应用程序的 Jest 测试 Animated.View

xcrun:错误:SDK "iphoneos" cannot be located

使用 resizeMode = contain时的图像对齐

React-Native 构建失败的应用程序:mergeDebugAssets

React Native Remote Debugger 在 Chrome 中显示缓存的包

如何删除不需要的expo 模块

无法加载 exp:// 出了点问题

在关闭 react-native 时更改 Switch 的 colored颜色

React Native Negative shadowOffset 创建顶部阴影

如何在 React Native 上获取设备的 ip?

React Native:当我从 XCode 运行应用程序时看不到 console.logs

opneUrl react-native 链接调用,mailto

如何将时刻日期转换为字符串并删除时刻对象

React Native 将状态中的数组值应用为 Picker 项

Tools > Android 菜单在 Android Studio 中不存在

如何在 react-native 中将文本复制到剪贴板?