如何解决TextInput从右到左开始,React本机
我有一个像图像一样的TextInput,当文本太长时,尽管我添加了CSS textAlign:'left',但它从右到左开始,但是它不起作用。它只是在android上发生,在ios上很好。有人遇到过同样的问题吗?
我的代码:
<View style={styles.myInput}>
<TextInput
numberOfLines={1}
style={styles.input}
placeholder="Tìm kiếm địa chỉ..."
value={search}
placeholderTextColor="gray"
onChangeText={(value) => setSearch(value)}
/>
<Ionicons
style={styles.inputIcon}
name="md-search"
color="gray"
size={20}
onPress={onSearch}></Ionicons>
</View>;
const styles = {
myInput: {
width: '100%',height: 45,top: 20,paddingHorizontal: 20,width: '90%',borderColor: 'gray',borderWidth: 1,backgroundColor: 'white',borderRadius: 5,position: 'relative',marginHorizontal: '5%',zIndex: 1,},input: {
height: 40,color: '#000',height: '100%',paddingRight: 30,};
解决方法
我有同样的问题。它仅在某些Android设备上发生过。我将其放在App.js文件中,并对其进行了修复。
import { I18nManager } from "react-native";
I18nManager.forceRTL(false);
I18nManager.allowRTL(false);
,
当inputText onblur时使用prop:selection({start:0})
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。