react-native - 键盘进入时Webview页面不滚动反应本机
问题描述
我正在使用 react-native-webview 来查看 html。Html 包含像聊天窗口这样的输入框。如果我在 iOS 中为这个 webview 提供 url,它可以正常工作。但是在 android 中,如果我点击输入框键盘重叠在输入框上。
代码:
<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>
解决方案
您正在使用基于百分比的大小,我猜您正在 Android 上对此进行测试,因为默认设置是在屏幕键盘打开时调整视图大小(它将 android:windowSoftInputMode="adjustResize" 添加到主 Activity在 AndroidManifest.xml 中查看 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.
推荐阅读
- amazon-web-services - 带有 Cloudfront 的 AWS S3 返回导致 CORS 问题的奇怪响应标头
- markdown - Markdown 方程未正确渲染
- apache-spark - 在 SparkSQL 中对数据集使用限制后应用过滤器时出现奇怪的结果
- kubernetes - hazelcast helm 模板,我如何传递我的 hazelcast.xml?
- api-platform.com - 设置集合的最大行数
- java - 如何在 IntelliJ 中配置 Kotlin?
- powershell - 通过appcmd检查iis模块是否存在
- angular - 如何创建 xOR Protractor ExpectedCondition 打字稿以等待元素通过(如果不相等)
- elasticsearch - 弹性如何定义给定另一个字段值的映射
- kubernetes - Kubernetes OIDC:组被忽略?