【问题标题】:TextInput start from right to left, React nativeTextInput 从右到左开始,React native
【发布时间】:2021-02-02 23:57:49
【问题描述】:

我有一个像图像一样的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,
  },
};

【问题讨论】:

    标签: react-native textinput


    【解决方案1】:

    我遇到了同样的问题。它只发生在某些 Android 设备上。我把它放在我的 App.js 文件中并修复它。

    import { I18nManager } from "react-native";
    
    I18nManager.forceRTL(false);
    I18nManager.allowRTL(false);
    

    【讨论】:

      【解决方案2】:

      inputText onblur 时使用 prop: selection({start: 0})

      【讨论】:

        猜你喜欢
        • 2017-02-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-12-31
        • 1970-01-01
        • 2019-02-06
        • 2018-04-17
        相关资源
        最近更新 更多