似乎我在创建显示时遇到了问题:与flexbox相当的内联样式.到目前为止,我已经实现了以下目标(红色和蓝色线条由边框功能控制,以帮助设计样式):

current layout given code

使用此代码:

var React = require('react-native');
var {
    View, 
    ScrollView, 
    Image,
    StyleSheet,
    Text, 
    TouchableHighlight,
} = React;

//additional libraries
var Parse = require('parse/react-native'); //parse for data storage
Icon = require('react-native-vector-icons/Ionicons'); //vector icons

//dimensions
var Dimensions = require('Dimensions');
var window = Dimensions.get('window');

//dynamic variable components
var ImageButton = require('../common/imageButton');
//var KeywordBox = require('./onboarding/keyword-box');

module.exports = React.createClass({
    render: function() {
        return (
            <View style={[styles.container]}>
                <Image 
                    style={styles.bg} 
                    source={require('./img/login_bg1_3x.png')}>
                    <View style={[styles.header, this.border('red')]}>
                        <View style={[styles.headerWrapper]} >
                            <Image 
                                resizeMode={'contain'}
                                style={[styles.onboardMsg]}
                                source={require('./img/onboard_msg.png')} >
                            </Image>
                        </View>
                    </View>
                    <View style={[styles.footer, this.border('blue')]}>
                        <ScrollView 
                            horizontal={false}
                            style={styles.footerWrapperNC}
                            contentContainerStyle={[styles.footerWrapper]}>
                            {this.renderKeywordBoxes()}
                        </ScrollView>
                    </View>
                </Image>
            </View>
        );
    }, 
    renderKeywordBoxes: function() {
        //renders array of keywords in keyword.js
        //and maps them onto custom component keywordbox to show in the onboarding
        //component
        var Keywords = ['LGBQT', '#BlackLivesMatter', 'Arts', 'Hip-Hop', 'History', 
        'Politics', 'Comedy', 'Fashion', 'Entrepreneurship', 'Technology', 'Business', 
        'International', 'Health', 'Trending', 'Music', 'Sports', 'Entertianment'];

        return Keywords.map(function(keyword, i) {
            return <TouchableHighlight 
                style={styles.keywordBox} 
                key={i}
                underlayColor={'rgb(176,224,230, 0.6)'} >
                <Text style={styles.keywordText} >{keyword}</Text>
            </TouchableHighlight>
        });
    }, 
    //function that helps with laying out flexbox itmes 
    //takes a color argument to construct border, this is an additional 
    //style because we dont want to mess up our real styling 
     border: function(color) {
        return {
          borderColor: color, 
          borderWidth: 4,
        } 
     },
});

styles = StyleSheet.create({
    header: {
        flex: 2,
    }, 
    headerWrapper: {
        flex: 1, 
        flexDirection: 'column', 
        alignItems: 'center',
        justifyContent:'space-around',
        marginTop: window.height/35,
    },
    onboardMsg: {
        width: (window.width/1.3), 
        height: (452/1287)*((window.width/1.3)),
    },
    footer: {
        flex: 7, 
        marginTop: window.height/35,
    }, 
    //container style wrapper for scrollview
    footerWrapper: {
        flexWrap: 'wrap', 
        alignItems: 'flex-start',
    },
    //non-container style wrapper for scrollview
    footerWrapperNC: {
        flexDirection:'row',

    },
    container: {
        flex: 1, 
        alignItems: 'center', 
        justifyContent: 'center',
    }, 
    bg: {
        flex: 1,
        width: window.width, 
        height: window.height, 
    },
    actionButtonIcon: {
        fontSize: 20,
        height: 22,
        color: 'white',
    },
    keywordText: {
        fontFamily: 'Bebas Neue', 
        fontSize: 18, 
        padding: 6, 
        fontWeight: 'bold',
        color: 'white', 
        letterSpacing: 1.5,
        textAlign: 'center'
    }, 
    keywordBox: {
        backgroundColor: 'transparent',
        margin: 3, 
        borderColor: 'rgb(176,224,230, 0.6)', 
        borderWidth: 1,
    },
});

但我想做到这一点:

Frame UI/UX

有什么 idea 吗?

编辑**答案:

需要将样式更改为以下内容:

//container style wrapper for scrollview
    footerWrapper: {
        flexWrap: 'wrap', 
        alignItems: 'flex-start',
        flexDirection:'row',
    },
    //non-container style wrapper for scrollview
    footerWrapperNC: {
        flexDirection:'column',
    },

所以在scrollView的列和行中使用flexDirection可以让子元素们保持在线

推荐答案

需要将样式更改为以下内容:

//container style wrapper for scrollview
    footerWrapper: {
        flexWrap: 'wrap', 
        alignItems: 'flex-start',
        flexDirection:'row',
    },
    //non-container style wrapper for scrollview
    footerWrapperNC: {
        flexDirection:'column',
    },

React-native相关问答推荐

如何在renderItem中显示每个项目的索引号,保持分页的前一个下一个按钮

如何根据设备主题更改React Native中状态栏的背景?

哪个版本的@stripe/stripe-react-native 模块支持 react native 0.62.0 typscript 模板?

如何渲染一个 svg 以在不同的窗口大小下动态地看起来相同?

如何将 react-native 图像从 expo-image-picker 上传到使用 multer 的 Express.js 后端

React Native Child Parent 通信

React Native - Expo:fontFamily 'SimpleLineIcons' 不是系统字体,尚未通过 Font.loadAsync 加载

在 TouchableOpacity 上创建 Raised凸起或Shadow阴影效果

react-navigation中的React-native android后退按钮

如何为 Picker 提供默认的Please select...选项?

submit提交后如何让 React Native TextInput 保持焦点?

如何在 React Native cli 中获取 SHA-1 密钥?

React Native Expo StackNavigator 重叠通知栏

如何将 Tensorflow 与 react-native 一起使用?

如何在 React Native 中使用 Jest

React Native EXPO Apple 上传失败

zoom 到指定的标记 react-native-maps

React Native:如何动态更改

React Native + Redux 基本认证

react-native 开始给出 Invalid 正则表达式无效错误