我的按钮没有在我的容器中散开 [英] My button isn't spreading across my container

查看:49
本文介绍了我的按钮没有在我的容器中散开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试以这种方式设置按钮样式,该样式将散布在我的视图中.目前,它在我的按钮的左侧和底部创建了白色边框(请参见随附的屏幕截图).

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

我的代码:

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

推荐答案

我考虑了react-native中使用的Button组件.只需删除在设置width时添加的wrapper flex.

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

这篇关于我的按钮没有在我的容器中散开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆