代码之家  ›  专栏  ›  技术社区  ›  Rigorous implementation

在react native中包含文本的行,不使用库

  •  6
  • Rigorous implementation  · 技术社区  · 7 年前

    试图复制以下设计,但无法复制。非常感谢您的帮助。

    enter image description here

    我从末尾开始尝试的代码如下,但该行覆盖了文本。

    <View>
      <View style={{ alignSelf:'center', borderBottomColor:'black', borderBottomWidth:1,height:'50%', width:'90%' }}/>
      <Text style={{ alignSelf:'center', paddingHorizontal:5 }}>Your class</Text>
    </View>
    
    1 回复  |  直到 7 年前
        1
  •  29
  •   Val    7 年前

    让它这样工作:

    <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