相關(guān)js源碼地址
node_modules\react-native\Libraries\CustomComponents\Navigator\
NavigatorNavigationBar.js
有個(gè)navigationStyles屬性 跟蹤在android下指向的是
node_modules\react-native\Libraries\CustomComponents\Navigator\NavigatorNavigationBarStylesAndroid.js
修改如下
var BASE_STYLES = {
Title: {
position: 'absolute',
bottom: 0,
left: 0,
right: 0,
/*alignItems: 'flex-center',*/
alignItems: 'center',
height: NAV_ELEMENT_HEIGHT,
backgroundColor: '#ff004e',
/*marginLeft: TITLE_LEFT,*/
marginLeft: 0,
paddingHorizontal : TITLE_LEFT,
},
使用示例
render() {
return (
<Navigator
initialRoute={{name: 'ScrollViewDemo', component: ScrollViewDemo}}
renderScene={this.renderScene}
navigationBar={<Navigator.NavigationBar
style={styles.navContainerRoot}
routeMapper={this.NavigationBarRouteMapper()
}
/>}
></Navigator>
);
}
...
const styles = StyleSheet.create({
/*高度不要設(shè)置 Navigator\NavigatorNavigationBar.js 中的navigationStyles NavigatorNavigationBarStylesAndroid已默認(rèn)定義了装畅,56*/
navContainerRoot: {
backgroundColor: '#81c04d',
alignItems: 'center',
justifyContent: 'center',
},