1
リアクト・ネイティブでは、私は<TextInput/>
ですが、フレックス・ボックス・スタイルを中心に設定しましたが、依然として左には座っていませんが、ちょうど垂直にセンタリングされています。私は簡単な<Text/>
でそれをテストし、それが正しく中心になります。React Native:なぜフレックスボックスを中心に<TextInput/>が中心ですか?
<TextInput/>
をフレックスボックスに集中させるにはどうすればよいですか?ここで
はコードです:
render() {
return (
<View style={{alignItems: 'center', justifyContent: 'center', flex: 1, }}>
<TextInput
style={{fontWeight: 'bold', height: 18, color: 'red'}}
placeholderStyle={{fontWeight: 'bold'}}
placeholderTextColor='red'
placeholder='Center Me'
/>
</View>
)
}
}
は、事前にありがとうございます!
EDIT - 追加のスタイルでは、あなたのTextInputコンポーネントにtextAlign: 'center'
を追加
<View style=style={{alignItems: 'center', justifyContent: 'center', flex: 1,}}>
<TextInput
onChangeText={this._handleName}
value={this.props.name}
placeholderTextColor='white'
placeholder='Put in name'
style={{
backgroundColor: 'black',
borderWidth: 0,
borderRadius: 15,
width: 250,
height: 70,
fontFamily: 'Roboto',
fontSize: 20,
textAlign: 'center',
}}
/>
</View>
私は答えとupvoteを受け入れる前に、更新されたスタイルと私のオリジナルのポストを見て、それはまだ左ではなく中央に揃えてください。私は何が欠けていますか? –
あなたの前のコメントがあるかどうか確認してください。私にお知らせください。 –