React-native-router-flux: Title in navigation bar is not centered in Android (7.0)

Created on 2 Aug 2017  路  4Comments  路  Source: aksonov/react-native-router-flux

Version

  • react-native-router-flux v4 (same version as in Example-app, but also tested with 4.0.0-beta.15 with same result)
  • react-native v0.44.0 (also tested v0.46)

  • Samsung S7

  • Android 7.0

Expected behaviour

Title in navigation bar to be centered in both iOS and Android

Actual behaviour

Title in navigaton bar is not centered in Android (but is centered in iOS).

Android (wrong):
router_flux_not_centered_title

iOS (correct):
router_flux_ios_centered_title

Steps to reproduce

You can use the Example app:

# Get the code
git clone [email protected]:aksonov/react-native-router-flux.git
cd react-native-router-flux/Example

# Install dependencies
yarn

# Run it
react-native run-android

I have tried to center the title by adding centering-styles to titleStyle- and headerStyle-props, but with no result. The best I can do is adding Android-specific left-padding/margin to titleStyle to make it centered, but that is difficult with different titles and different screen sizes.

Most helpful comment

Ah, thanks!

<Scene
  ...
  titleStyle={{alignSelf: 'center'}} 
/>

... solved the issue.

All 4 comments

Ah, thanks!

<Scene
  ...
  titleStyle={{alignSelf: 'center'}} 
/>

... solved the issue.

I created a PR #2172 with the example updated with this prop, if that is wanted in the example.

For me it worked with
<Scene ... titleStyle={{ textAlign: 'center', flex: 1 }} />

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rafaelcorreiapoli picture rafaelcorreiapoli  路  3Comments

GCour picture GCour  路  3Comments

wootwoot1234 picture wootwoot1234  路  3Comments

jgibbons picture jgibbons  路  3Comments

willmcclellan picture willmcclellan  路  3Comments