Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React native base title centre alignment

I’m using react native base. I want to centre align the title in iOS and android both, since text is long it hides it with “…”. Applying flex:3 shows title fully but it don't centre align it. Even applying alignItems: 'center',alignSelf: 'center' don't help.

I've tried different option unable to fix it. How can I fix it?

Code:

 <Header  iosStatusbar="light-content" androidStatusBarColor='#000' >
<Left style={{flex:1}}>
<Button transparent onPress={() =>  this.navigateCustom("goBack")}>
 <Icon name="arrow-back" />
 </Button>
</Left>

    <Body style={{flex:3,}}>
     <Title>THIS IS A LONG TITLE TEST</Title>
   </Body>

  <Right style={{flex:1}}>
  <Button transparent onPress={()=> this.navigateCustom("DrawerOpen") }>
     <IconEvil  name={"menu"}  style={{ color: "rgb(255,255,255)", fontSize:30}}/>
     </Button>
  </Right>
      </Header>

EDIT: after applying flex:1 and centre alignment to body enter image description here

like image 777
devedv Avatar asked Jan 23 '18 09:01

devedv


1 Answers

You could use justifyContent and alignItems both to center like below with flex:1:

 <Body style={{ flex: 1,  justifyContent: 'center', alignItems: 'center' }}>
   <Title>THIS IS A LONG TITLE TEST</Title>
 </Body>
like image 182
Lotus91 Avatar answered Oct 11 '22 21:10

Lotus91