Line with text in react native without using a library

时间:2017-12-18 05:55:20

标签: react-native react-native-android jsx react-native-ios

Trying to replicate the below design but not able to. Will appreciate any help with this.

enter image description here

Code that I tried from my end is as below but the line overwrites the text.

<View>
  <View style={{ alignSelf:'center', borderBottomColor:'black', borderBottomWidth:1,height:'50%', width:'90%' }}/>
  <Text style={{ alignSelf:'center', paddingHorizontal:5 }}>Your class</Text>
</View>

1 个答案:

答案 0 :(得分:6)

Made it works this way:

<View style={{flexDirection: 'row'}}>
    <View style={{backgroundColor: 'black', height: 2, flex: 1, alignSelf: 'center'}} />
    <Text style={{ alignSelf:'center', paddingHorizontal:5, fontSize: 24 }}>Your class</Text>
    <View style={{backgroundColor: 'black', height: 2, flex: 1, alignSelf: 'center'}} />
</View>

enter image description here