当键盘进入反应本机时,Webview页面不滚动

时间:2019-12-09 08:32:48

标签: react-native react-native-webview

我正在使用react-native-webview查看html。 HTML包含输入框,如chatwindow。如果我在iOS中将此URL赋予此webview,则它可以正常工作。但是在android中,如果我单击inputbox,则输入框中的键盘重叠。

代码:

<WebView
    originWhitelist={["https://*", "http://*", "file://*", "sms://*", "tel://*"]}
    automaticallyAdjustContentInsets={false}
    source={{ uri: 'http://sample.com/sample/chat.html' }} 

    scalesPageToFit={false}
    injectedJavaScript={jsCode}
    javaScriptEnabled={true} domStorageEnabled={true}
    }
>
</WebView>

2 个答案:

答案 0 :(得分:0)

您正在使用基于百分比的大小,并且我想您正在Android上对此进行测试,默认情况下是在打开屏幕键盘时调整视图大小(它将android:windowSoftInputMode =“ adjustResize”添加到AndroidManifest.xml中的主要Activity请参见github.com/facebook/react-native中的这一行代码)

为避免此尺寸调整问题,您有两个选择-

Change adjustResize to adjustPan in the AndroidManifest.xml
Don't use percentage based sizes for the logo. Or if it's an Image, just set the width and allow the height to be set based on the image size.

答案 1 :(得分:0)

最适合我的是使用“ KeyboardAvoidingView”包装,如下所示:

fixed=true / false
相关问题