0

I got this Custom Header:

export const HeaderBar = (props) => {
  return (
    <View style={styles.containerHeader}>
      <View style={styles.containerImage}>
        <Image source={logo} style={styles.logo} />
      </View>
    </View>
  );
};

const styles = StyleSheet.create({
  logo: {
    width: 90,
    resizeMode: "contain",
    alignSelf: "center",
  },
});

This shows a header bar with a logo in the center of the bar.

My app.js

<HomeStack.Screen
  name="TitleDetails"
  component={TitleDetails}
  options={{
    headerTitle: (props) => <HeaderBar />,
    headerStyle: { backgroundColor: "#3B9B88" },
  }}
/>

The problem is that when I use the back button of React Navigation, the header moves a little to the right and therefore the logo is off-center.

How can I fix this?

1
  • add back button in your custom header instead of back button of react navigation Commented Oct 13, 2020 at 11:30

1 Answer 1

1

When you add the back button, your logo is get center of the remaining width. You can remove the center align css and use the position and set it by yourself at the center

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.