【问题标题】:How to align multiline text in react native如何在本机反应中对齐多行文本
【发布时间】:2019-05-17 12:20:42
【问题描述】:

在我的屏幕中,我需要将文本拆分为列视图,并且需要将右侧文本与左侧文本对齐。另外,需要逐行显示整个文本。测试给出了一些高度、宽度、位置:绝对但没有用。知道如何解决这个问题吗?

我将发布我当前的代码和屏幕截图供您参考。

非常感谢您的帮助

   <View style={styles.twoCol}>

     <View style={styles.leftField}>
       <Text style={styles.leftFieldTitle}>Location:</Text>
      </View>

     <View style={styles.locationRightSide}>
       <Text style={styles.rightFieldTitle}>{location}</Text>
     </View>

   </View>

const styles = StyleSheet.create({

     twoCol: {
           alignItems: 'center',
           flexDirection: 'row',
           marginTop: 25,
         },
      leftField: {
            alignItems: 'flex-end',
            width: '25%',
        },  
       leftFieldTitle: {
            fontWeight: '700',
            color: 'black'
        },

        },
        locationRightSide: {
            width: '70%',
            alignItems: 'flex-start',
            paddingLeft: 10
        },
      rightFieldTitle: {
            fontSize: RF(2.8),
            color: 'black'
        },
        )}

【问题讨论】:

  • 在 expo 中运行您的代码并将其链接到您的帖子,我会为您修复它

标签: react-native text alignment multiline


【解决方案1】:

问题解决了!!!感谢大家!

<View style={{
                                padding: 10,
                                flexDirection: "row",
                                marginLeft: 10,
                                marginRight: 5,
                                marginTop: 5,
                                marginBottom: 3,
                                justifyContent: "flex-start",
                                width: '95%',
                            }} >
                                <View style={{
                                    position: 'absolute',
                                    marginTop: 10
                                }}>
                                    <Text style={styles.leftFieldTitle}>Location:</Text>
                                </View>
                                <View style={{ marginLeft: '26%' }}>
                                    <Text style={styles.rightFieldTitle}>{location}</Text>
                                </View>
                            </View>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-21
    • 1970-01-01
    • 2021-10-01
    • 2019-09-28
    • 2021-12-13
    相关资源
    最近更新 更多