Make sure to check the issues before resulting to stack overflow, normally more helpful.issue regarding your problem But as himanshu said in comments you need to access the title style property to adjust the title how you want.
As shown in the issue, i presume you've already managed to find a solution as this was a while ago. But for anyone else coming across this issue it may be helpful.
In year of 2018, after react-navigation v2 release (7 Apr 2018), for some reason alignSelf was not working anymore. Here it is the new working way, using headerLayoutPreset. from @HasanSH:
The accepted answer only works for me if there isn't a back button present on the left-hand side. In that case, you need to set an empty View to the right-hand side to properly center it.
The best way to do that is by implementing what is listed in the documentation:
Inside the StackNavigatorConfig assign an optional property, as follows:
createStackNavigator({
{ ... // your screens},
{ ...,
headerLayoutPreset: 'center' // default is 'left'
})
headerLayoutPreset - Specifies how to lay out the header components.
By doing this you don't have to mess up with the styling at all. And it would be applied to all the nested screens in that stack.
Although headerLayoutPreset technically works, it should display a message informing that it is deprecated for expo users.
The implementation is as follows:
React-Navigation v5.x Update:
As per @Ewan ' s rectification, if you are using React-Navigation v5.x, you cannot pass parameters to createStackNavigator(). Therefore, you should implement it as follows: