反应本机标题标题位置

时间:2017-09-03 10:28:22

标签: react-native navigation styles react-native-android

enter image description here

如何在反应原生中更改标题标题的位置:

代码是:

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我需要在左边的右后按钮标题

请帮助

2 个答案:

答案 0 :(得分:2)

对于android我添加了这一行:

headerTitleStyle: {
   alignSelf: (Platform.OS === 'android') ? 'flex-end' : 'center'
}

例如对于Home sense我使用如下代码:

Home: {screen: BookViewContainer , navigationOptions: ({navigation}) => ({
  title: 'test title',
  headerStyle: {
    backgroundColor: 'red'
  },
  headerTintColor: 'blue',
  headerTitleStyle: {
    alignSelf: (Platform.OS === 'android') ? 'flex-end' : 'center'
  }
 })},

答案 1 :(得分:0)

另一种棘手的方法是使用absolutezindex道具实施,如果您使用的是反应原生基础

<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>

see image here !!

相关问题