Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/433.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 是否有一种方法可以将文本组件的全部内容包装在react native的父视图中?_Javascript_Reactjs_React Native_Textview - Fatal编程技术网

Javascript 是否有一种方法可以将文本组件的全部内容包装在react native的父视图中?

Javascript 是否有一种方法可以将文本组件的全部内容包装在react native的父视图中?,javascript,reactjs,react-native,textview,Javascript,Reactjs,React Native,Textview,我正在react native中创建一个屏幕,其中必须在父视图上显示文本。如何显示整个文本 起初我认为这是一个文本没有包装的问题,所以我试着从一个问题解决这个问题 我希望渲染所有文本,但仅渲染第一行文本正在正确渲染,但当您放置属性width=80%时,它会将内容包装到新行。我使用红色作为父视图,以提高文本清晰度。请尝试运行下面的代码,如果您遇到任何问题,请告诉我。我会尽力帮你的,伙计 <View style={{ backgroundColor: 'red', borderRadius:

我正在react native中创建一个屏幕,其中必须在父视图上显示文本。如何显示整个文本

起初我认为这是一个文本没有包装的问题,所以我试着从一个问题解决这个问题


我希望渲染所有文本,但仅渲染第一行

文本正在正确渲染,但当您放置属性
width=80%
时,它会将内容包装到新行。我使用红色作为父视图,以提高文本清晰度。请尝试运行下面的代码,如果您遇到任何问题,请告诉我。我会尽力帮你的,伙计

<View style={{ backgroundColor: 'red', borderRadius: 5 }}>
            <Text style={{  backgroundColor: 'transparent',
                            textAlign: 'center',
                            fontSize: 18,
                            color: '#005F6A',
                            marginTop: '5%'
                        }}>
                        Text the first & Text the second & text the third, Text the fourth & text the fifth
                    </Text>
                </View>

给第一个发短信&给第二个发短信&给第三个发短信,给第四个发短信&给第五个发短信

效果很好,但当我添加
marginTop:'90%'
文本将完全消失,但父视图remainsIt不应消失,我还将
marginTop
增加到90%,文本仍然存在。虽然它增加了父视图的大小,但应该可以,因为文本需要一些空间来扩大其空间。是的,你说得对,我也放了
flexDirection:“行”
,一切都很好,谢谢
<View style={{ width: '100%', height: '15%', position: 'absolute', alignSelf: 'center', backgroundColor: 'rgba(255, 255, 255, 0.4)', borderRadius: 5, marginTop: '90%', }}>
    <Text style={{ width: '80%', backgroundColor: 'transparent', alignSelf: 'center', textAlign: 'center', fontSize: 18, color: '#005F6A', marginTop: '5%' }}>
        {`Text the first &
        Text the second &
        text the third`}
     </Text>
</View>
<View style={{ backgroundColor: 'red', borderRadius: 5 }}>
            <Text style={{  backgroundColor: 'transparent',
                            textAlign: 'center',
                            fontSize: 18,
                            color: '#005F6A',
                            marginTop: '5%'
                        }}>
                        Text the first & Text the second & text the third, Text the fourth & text the fifth
                    </Text>
                </View>