正如您在docs 中看到的那样,react-native-paper 中标题的默认位置是左对齐的。我已经看到多个关于如何为 Android Native 和 React Native 的 StackNavigator 实现居中标题的问题和答案,但我没有运气用react-native-paper
.
到目前为止,我已经尝试使用style
参数 inAppbar.Header
传入{ textAlign: 'center' }
or { flexDirection: 'row', justifyContent: 'space-between' }
,但似乎没有任何效果。我对 react-native-paper 缺乏关于覆盖的文档印象不深,但我仍然希望有一种方法可以做我正在寻找的东西。
const styles = { header: { textAlign: 'center' }}
<Appbar.Header style={styles.header}>
<Appbar.Action icon="close" onPress={() => this.close()} />
<Appbar.Content title={title} />
<Button mode="text" onPress={() => this.submit()}>
DONE
</Button>
</Appbar.Header>
Run Code Online (Sandbox Code Playgroud)
考虑到title
accept a node
,它可以用来显示一个反应组件。
如何在所有设备上强制将标题居中?