我的本机应用程序中有一个TextInput
。当我设置值prop且该值比TextInput
的长度长时,它将显示从头开始而不是从头开始的文本。在iOS中可以正常使用,这似乎是Android问题。有没有一种方法可以对齐文本,使其从TextInput
的开头显示,还是首选?
这是我看到的:
这就是我想要的:
这是我的代码
<TextInput
defaultValue={address}
ref="searchInput"
autoCorrect={false}
style={searchStyles.searchInputField}
placeholderTextColor={'#ddd'}
placeholder="Location"
onChangeText={query => this.search(query)}
/>
<TextInput value={address} autoFocus={true} selection={{start:0, end:0}} />
也许有更好的方法可以做到这一点,但这是我想出的希望对其他人有所帮助的方法。
或同时更新文本和选择:
this.inputRef && this.inputRef.setNativeProps({ text: value, selection: { start: 0, end: 0 } })