Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
275 views
in Technique[技术] by (71.8m points)

react native - Inline elements implementation

I want to create Text components and to display them in a row , like span elements in html. If i'm doing it this way:

<View>
  <Text> Start here, </Text> <Text> finish here </Text>
</View>

line is broken between them and it looks like:

Start here,
finish here

How can i prevent line breaking and display them on the same line?

question from:https://stackoverflow.com/questions/34704882/inline-elements-implementation

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Just set the correct flexDirection. Default is column.

<View style={{flexDirection: 'row'}}>
 <Text> Start here, </Text> <Text> finish here </Text>
</View>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...