2017-01-07 100 views
9

我想知道为什么我的文本在react-native中得到这些奇怪的padding。我想尽一切办法来获得完美的文本,但似乎没有任何工作的唯一工作是paddingVerticalpaddingHorizontal,但它太hacky和不可靠。反应本机Android文本组件额外填充

<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从我的HTC

enter image description here

截图

enter image description here

+0

你能否更新你的问题以添加更多信息?在屏幕截图中,您试图去除的额外填充究竟在哪里? –

+0

你使用自定义字体吗(我不认为Roboto是默认的)?这种行为是特定于Android还是iOS?我在Android上遇到了类似的问题,我发现了一种hacky解决方案:http://stackoverflow.com/questions/41570343 – henkimon

回答

-1

你可以添加到风格:

lineHeight: 70, 
paddingTop: -6, 

这就是结果:result