react-native基于本机的视图justifyContent在<content>中不起作用

时间:2018-09-08 05:55:19

标签: react-native native-base

我希望按钮位于屏幕中央。我知道视图没有拉伸,但是如何解决?

render() {
    return (
            <Container>
                <Header>
                    <Left>
                        <Button transparent>
                            <Icon name="menu"/>
                        </Button>
                    </Left>
                </Header>
                <Content>
                    <View style={{ flex:1, justifyContent: "center", alignItems: "center"}}>
                        <Button block info style={{margin: 10}}>
                            <Text>AAAA</Text>
                        </Button>
                        <Button block info style={{margin: 10}}>
                            <Text>BBBB</Text>
                        </Button>
                    </View>
                </Content>
                <Footer/>
            </Container>
        );

1 个答案:

答案 0 :(得分:0)

尝试

render(){
    return(
    <View style={{ flex:1,
        justifyContent: 'center', 
        alignItems: 'center'}}>
        <Button 
        color="#4682b4"
        title="Click me"
        onPress={() => Alert.alert('Clicked')}/>
        </View>
        );
    }

您为什么要服用<Container><Content>