2016-05-21 7 views
10

TextInputコンポーネントのプレースホルダテキストを揃える理由は何ですか?私はすでにスタイルコンポーネントを以下のように使用しようとしています。このためにも、そのようなものがないようです。TextInput placeHolder Alignment

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

私の場合、テキストは中央に配置されていません。私はマテリアルキットを使用しています。何が問題なのでしょうか?またはそれはうまく働いています – santhosh

答えて

18

あなたのtextInputスタイルにtextAlign: 'center'を追加します。

+0

テキストは私の場合は中心に揃えられていません私はマテリアルキットを使用しています。何が問題なのでしょうか?またはそれはうまく動作している – santhosh

+0

は、魅力的な作品..... –