反应本土头题位置
问题描述:
如何更改标题标题的位置,就在反应本土:
代码:
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
})},
在IOS它在中心显示标题,背在按钮向左,右菜单按钮,它的确定,但为Android,我需要在正确的标题和后退按钮左
请帮助
答
为Android我加入这一行:
headerTitleStyle: {
alignSelf: (Platform.OS === 'android') ? 'flex-end' : 'center'
}
例如用于家庭意义上,我使用如下代码:
Home: {screen: BookViewContainer , navigationOptions: ({navigation}) => ({
title: 'test title',
headerStyle: {
backgroundColor: 'red'
},
headerTintColor: 'blue',
headerTitleStyle: {
alignSelf: (Platform.OS === 'android') ? 'flex-end' : 'center'
}
})},
答
另一个棘手的方法是用absolute
和zindex
道具来实现,如果你'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>