Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

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

unable to add border bottom in react native

I am trying to make a registration form.

I created a file named Regform.js under the component directory.

I am unable to get border-bottom for the text Registration

Here is the demo link demo working link

please let me know, where I am doing wrong

enter image description here

Component/Regform.js

import * as React from 'react';  

import {   
 Text,   
 View,   
 StyleSheet,    
 TextInput,  
 TouchableOpacity   
 } from 'react-native'; 


 export default class Regform extends React.Component {  
  render() {  
   return (  
    <View>  
     <Text style={styles.header}> Registration </Text> 

      <TextInput style = {styles.textinput}
      underlineColorAndroid = "transparent"
      placeholder = "Enter Your Name"
      placeholderTextColor = "#9a73ef"
      onChangeText = {this.handleName}/>

      <TextInput style = {styles.textinput}
      underlineColorAndroid = "transparent"
      placeholder = "Enter Your Email"
      placeholderTextColor = "#9a73ef"
      autoCapitalize = "none"
      onChangeText = {this.handleEmail}/>

    </View>  
   );  
  }  
 } 


 const styles = StyleSheet.create({  

      header: {  
        fontSize: 36,
        alignself: 'self',
        color: 'red',
        marginBottom: 30,
        borderBottomColor: 'red',
        borderBottomWidth: 2
      },
      textinput: {
        fontSize: 18,
        alignself: 'self',
        color: 'black',
        marginBottom: 30,
        borderBottomColor: 'grey',
        borderBottomWidth: 2
      }
  }); 
question from:https://stackoverflow.com/questions/51962558/unable-to-add-border-bottom-in-react-native

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

1 Answer

0 votes
by (71.8m points)

It seems borderBottom doesn't work for the Text component. You can either add a View wrapper and supply borderBottom to it or add a TextInput and make editable={false}

<View style={styles.headerWrapper}>
    <Text style={styles.header}> Registration </Text>
 </View>
...

headerWrapper: {
    borderBottomColor: 'red',
    borderBottomWidth: 2,
    marginBottom: 30,
},
header: {
    fontSize: 36,
    alignSelf: 'auto',
    color: 'red',

},

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...