繁体   English   中英

在本机上在Android上使用TextInput存在问题

[英]There is an issue for using TextInput on android in react native

我在使用React本机在android上使用TextInput时遇到问题,我使用了以下代码。

导出默认类的App扩展了Component {render(){return(

  </View>
);

}}

然后屏幕如下:

点击TextInput之前的屏幕截图

当我点击TextInput视图时,屏幕出现,就像使用keyboardavoidingview一样。

点击TextInput后的屏幕截图

它在android上,但是在ios上没有任何作用。 我没有使用任何其他组件。

我的package.json如下:

{
  "name": "example",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.6.1",
    "react-native": "0.57.7",
    "react-native-gesture-handler": "^1.0.10",
    "react-native-indicators": "^0.13.0",
    "react-native-maps": "^0.22.1",
    "react-native-maps-directions": "^1.6.0",
    "react-native-modal": "^7.0.1",
    "react-navigation": "^3.0.4"
  },
  "devDependencies": {
    "babel-jest": "23.6.0",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.50.0",
    "react-test-renderer": "16.6.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

在Android上,尽管我从未使用过该组件,但为什么会有类似使用KeyboardAvoidingView的效果? 为什么在ios上还可以呢? 听到您的进步我感到非常高兴。 谢谢。

每当您使用TextInput ,建议您将Scrollview用作它的父视图,并带有prop keyboardShouldPersistTaps="always" 每当键盘弹出时,这将创建均匀性。

编辑:

<View style={{flex:1}}>
    <ScrollView keyboardShouldPersistTaps="always">
      <View style={{paddingTop:20}}> //Inside ScrollView flex doesn't work so use padding to control spacing 

          // Add your <TextInput> Tag here !!

       </View>
     </ScrollView>
</View>

希望可以为您服务。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM