Reputation: 714
how can I change position of header title to right in react native:
code is:
Home: {
screen: BookViewContainer ,
navigationOptions: ({navigation}) => ({
headerRight: <DrawerIcon iconDefault='menu' tintColor={Constants.styles.secondColor} size={30}/>,
title: Strings.book_label,
headerStyle: {
backgroundColor: Constants.styles.mainColor
},
headerTintColor: Constants.styles.secondColor
})},
In ios it's show title in center, back button in left, menu button in right and it's ok but for android i need to title in right and back button in left
please help
Upvotes: 1
Views: 7599
Reputation:
Another tricky way is to implement with absolute
and zindex
props, if you're using react-native-base
<Button transparent>
<View style={{}}>
<Icon name="more-vert" style={{
zIndex:-999 ,
position:'absolute',
right:0,
top:0,
}}/>
<Picker
style={{
zIndex:999,
position:'absolute',
//right:0,
top:-35,
backgroundColor:'transparent',
}}
onValueChange={()=>{}}
mode="dropdown">
<Item label="Wallet" value="key0" />
<Item label="ATM Card" value="key1" />
</Picker>
</View>
</Button>
Upvotes: 0
Reputation: 714
for android i added this line:
headerTitleStyle: {
alignSelf: (Platform.OS === 'android') ? 'flex-end' : 'center'
}
for example for Home sense I use like below code:
Home: {screen: BookViewContainer , navigationOptions: ({navigation}) => ({
title: 'test title',
headerStyle: {
backgroundColor: 'red'
},
headerTintColor: 'blue',
headerTitleStyle: {
alignSelf: (Platform.OS === 'android') ? 'flex-end' : 'center'
}
})},
Upvotes: 2