react-native native-base视图justifyContent不起作用

问题描述 投票:0回答:1

我希望按钮位于屏幕的中心。我知道View没有拉伸,但如何解决?

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>
        );
react-native native-base
1个回答
0
投票

试试这个

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

你为什么选择<Container><Content>

© www.soinside.com 2019 - 2024. All rights reserved.