2016-05-21 19 views
10

TextInput bileşeni için yer tutucu metnini hizalamanın en iyi yolu nedir? Aşağıda açıklanan stilleri bileşenini kullanmaya çalıştım. Bunun için de var ve özellik yok.TextInput placeHolder Hizalama

render() { 
    return (
     <View style={styles.container}> 
     <View style={styles.container}> 
      <TextInput 
       style={styles.textInput} 
       onChangeText={(text) => this.setState({ 
        username: text 
       })} 
       placeholder='Add Username' 
      /> 
      <Button onPress= {_ => this.onClick() } style={styles.button} > 
        + Add User 
      </Button> 
     </View> 

     </View> 
    ); 
} 

onClick(){ 
    alert(this.state.username); 
} 

} 

const styles = StyleSheet.create({ 
container: { 
    flex: 1, 
    justifyContent: 'center', 
    alignItems: 'center', 
}, 
textInput: { 
    height: 40, 
    width: 200, 
    justifyContent: 'center', 
    alignItems: 'center', 
    alignSelf: 'center', 
    borderColor: 'gray', 
    borderWidth: 1, 
}, 
    button: { 
     backgroundColor: 'grey', 
     color: 'black', 
     fontSize: 15, 
     width: 200, 
     borderWidth: 1 
    }, 

}); 
+0

Metin benim durumumda hizalanmamış durumda malzeme seti kullanıyorum. Sorun ne olabilir? ya da iyi çalışıyor – santhosh

cevap

18

textInput stilinize textAlign: 'center' ekleyin.

+0

Metin benim durumumda ortada hizalanmamış malzeme-kit kullanarak. Sorun ne olabilir? veya iyi çalışıyor – santhosh

+0

bir çekicilik gibi çalışıyor ..... –