[英]react-native using custom fonts
我正在使用 react native custom fonts并且存在问题。 默认情况下,文本居中,当我使用字体时,文本不居中。 这是代码。
<TextInput
style={{
height:40,
width:width-10,
margin:5,
backgroundColor:"#eee",
borderRadius:5,
paddingLeft:20,
fontFamily:FONTS.medium // if I comment this line then placeholder and text input is on center.
}}
placeholder="Search Here"
/>
注意:我已经用多个 fonts 检查过它并且有同样的问题。
尝试使用includeFontPadding
或lineHeight
移除间距。
<Text
style={{
backgroundColor: 'red',
//lineHeight: 92,
fontSize: 24,
color: '#000000',
fontFamily: 'Roboto-Regular',
includeFontPadding: false}}>
Search Here
</Text>
如果这不起作用,请检查字体本身是否有间距。 打开字体文件*.ttf,检查文字是否有大间距。
使用 includeFontPadding 属性,它将删除默认空间
<Text style={{
includeFontPadding: false
}}>
Search Here
</Text>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.