'TextInput start from right to left, React native
I have a TextInput like in the image, when the text too long, it starts from right to left although I added CSS textAlign: 'left' but it does not work. It happens just on android, on ios it's good. Anybody got the same problem before?
My code:
<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>
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
}
Solution 1:[1]
use prop: selection({start: 0}) when inputText onblur
Solution 2:[2]
I had the same issue. It only happened with some Android devices. I put this in my App.js file and it fixed it.
import { I18nManager } from "react-native";
I18nManager.forceRTL(false);
I18nManager.allowRTL(false);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Noname |
Solution 2 | bolarson |