【发布时间】:2019-09-28 00:50:12
【问题描述】:
我面临一个问题,将按钮的文本垂直居中对齐,但它仍然略低于正中。
我从文档中找到了includeFontPadding,它暗示了某些第三方字体存在一些差异。
字体在 iOS 设备中看起来很合适,但在 Android 设备中不正确。
https://facebook.github.io/react-native/docs/text-style-props#includefontpadding
设置为 false 以删除旨在为某些上升/下降腾出空间的额外字体填充。对于某些字体,此填充可能会使文本在垂直居中时看起来略微错位。为了获得最佳结果,还将 textAlignVertical 设置为居中。默认为真。
<Button
style={[style.button]} block >
<Text>Setup Now</Text>
</Button>
按钮样式:
export default {
button: {
elevation: null,
shadowColor: null,
shadowOffset: null,
shadowOpacity: null,
shadowRadius: null
}
}
【问题讨论】:
-
请同时添加使用的样式。
-
@Tim 样式添加
-
你使用的是标准的 react-native 按钮吗?
-
@Tim:是的,我使用的是标准按钮
-
抱歉再次提问,能否提供MCVE?我认为否则没有人可以帮助你
标签: android reactjs react-native styles text-alignment