My button isn't spreading across my container

浪子不回头ぞ 提交于 2019-12-11 16:44:01

问题


I am trying to set my button style that way, it will be spread across my View. Currently its creating white border on the left and on the bottom of my button (see attached screenshot).

My code:

let {width, height} = Dimensions.get('window');
        let photoWidth = width/4;

return (
            <View style={{width: width, height: 500}}>
                <ScrollView style={{width: width, height: height}}>
                    <View style={{flexDirection: 'row', width: width, flexWrap: 'wrap'}}>
                    {
                        this.state.photos.map((p, i) => {
                            return (
                                <SelectedPhoto
                                    key={i}
                                    index={i}
                                    style={{
                                        width: photoWidth,
                                        height: photoWidth,
                                    }}
                                    limit={this.state.supportLength}
                                    photo={p}
                                    onSelectPhoto={this.onSelectPhoto}
                                    onDeselectPhoto={this.onDeselectPhoto}
                                />
                            );
                        })
                    }
                    </View>
                </ScrollView>
                <View style={{ flexDirection:"row", flexWrap: 'wrap', width: width }}>
                    <Button

                        onPress={this.onNext}  
                        containerViewStyle={{width: width}}
                        backgroundColor={Colors.red}
                        title='NEXT' />
                </View>             
            </View>
        );

回答1:


I consider Button component you used from react-native. Just remove wrapper flex you added as you set width to it.

<Button
   onPress={this.onNext}  
   containerViewStyle={{width: width}}
   backgroundColor={Colors.red}
   title='NEXT' />


来源:https://stackoverflow.com/questions/50622943/my-button-isnt-spreading-across-my-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!