textAlignVertical:'top'
hightを設定したら機能しない。
初期表示されるhightが変わるだけで、行数を制限するわけではない。
改行すればどんどん入力スペースは下に拡張していく。
<TextInput multiline = {true}
numberOfLines = {2} // 2
style={{textAlignVertical:'top', borderColor: 'gray', borderWidth:1 , backgroundColor:'white',fontSize:20,borderRadius:5,margin:10}}
onChangeText={(text) => this.setState({question:text})}
value={this.state.question}
/>
<TextInput multiline = {true}
numberOfLines = {4}
style={{textAlignVertical:'top', borderColor: 'gray', borderWidth:1 , backgroundColor:'white',fontSize:20,borderRadius:5,margin:10}}
onChangeText={(text) => this.setState({question:text})}
value={this.state.question}
/>
デザインの関係上マルチラインにしたいが、改行することで高さが変わるのは望ましくない場合がある。
その場合はautogrow={false}とmaxHeight={99}を設定する。
<Text style={{fontSize:20}}>問題</Text>
<TextInput multiline = {true}
scrollEnabled={true}
numberOfLines={4}
autogrow={false} //セットで設定しないと効かない
maxHeight={60} //セットで設定しないと効かない
style={{textAlignVertical:'top', borderColor: 'gray', borderWidth:1 , backgroundColor:'white',fontSize:20,borderRadius:5,margin:10}}
onChangeText={(text) => this.setState({question:text})}
value={this.state.question}
/>