Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Title is not aligning to center #3071

Closed
ggunti opened this issue Jun 9, 2018 · 4 comments
Closed

Title is not aligning to center #3071

ggunti opened this issue Jun 9, 2018 · 4 comments

Comments

@ggunti
Copy link

ggunti commented Jun 9, 2018

Version

  • react-native-router-flux v4.0.0-beta.31

Expected behaviour

Title will be aligned to center.

Actual behaviour

Title still remaining on the left side (default).

Steps to reproduce

  <Router>
    <Scene
      key="root"
      titleStyle={{ alignSelf: 'center' }}
    >
      <Scene
        key="splash"
        component={Splash}
        hideNavBar
        initial
      />
      <Scene
        key="login"
        component={Login}
        title="EasyYard Login"
        type="reset"
      />
      <Scene
        key="home"
        component={Home}
        title="EasyYard Home"
        //initial
      />
    </Scene>
  </Router>

Remark: On version v4.0.0-beta.28 it is working perfectly.

@m-vdb
Copy link

m-vdb commented Jun 28, 2018

Having the same issue. Only on Android

@m-vdb
Copy link

m-vdb commented Jun 28, 2018

Here is what worked for me:

const styles = StyleSheet.create({
     navigationBarTitleStyle: {
       // centering for Android
      flex: 1,
      textAlign: 'center'
  }
});

...
<Scene
    titleStyle={styles.navigationBarTitleStyle}
    ...
...

@aksonov aksonov closed this as completed Aug 8, 2018
@haddow777
Copy link

The problem with aligning the title manually is that it becomes lopsided once icons like the back button are added. It is centered in an element that has been pushed over by the icon element.
Blah

@haddow777
Copy link

Okay, I found it out. Don't style the title to center it, as I mentioned before, it will look ugly once icons added to back title text.

headerLayoutPreset="center"

Place the above in your top level scene. For some reason, on Android the title is defaulted to the left, even though the documentation says it's supposed to default to the center. Here's mine:

<Scene
  key="root"
  headerLayoutPreset="center"
>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants