android - TextInput 光标移动到显示/隐藏密码的开头

标签 android react-native

我在显示或隐藏密码值时遇到 TextInput 光标问题,当用户触摸显示密码按钮时,光标移动到 Android 的开头,iOS 正常工作。

这是揭示密码的功能:

displayPass(){
    this.setState({
        hiddenPass: !this.state.hiddenPass
    });
}

这是文本输入

<TextInput onChangeText = {(pass) => this.setState({pass})} 
  secureTextEntry = {this.state.hiddenPass} />

这是按钮:

<TouchableOpacity onPress = {this.displayPass.bind(this)}>
    <Text style = {styles.textReveal}>{this.state.hiddenPass ? "Reveal Password" : "Hide Password"}</Text>
</TouchableOpacity>    

最佳答案

DISCLAIMER: For me, it was impossible to fix this under Expo 32. Playing with cursor position, focus/blur and setNativeProps did not solve it.

如果您需要具有隐藏和显示功能的密码输入,您最好的选择是:

关于android - TextInput 光标移动到显示/隐藏密码的开头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48893034/

相关文章:

android - 应用程序在更改样式下的主题时崩溃

Android 选项卡布局帮助

javascript - 为什么我收到错误 : TypeError: Cannot read property 'map' of undefined?

reactjs - React-Native 抽屉式菜单在堆栈导航器屏幕内打开

reactjs - React Native - 在导航中的屏幕之间移动错误

android - 行触摸了 id 名称为 "Corona SDK"的 gotoScene

android - 为什么我不能实例化新变量?

android - 主类中的 onCreate 扩展了 Application 从未被调用

react-native - 切换 React Native 元素的可见性?

react-native - React Native Android中如何将源码目录下的图片加载到webview