android - Android 上的 KeyboardAvoidingView 在键盘上方创建一个灰色框
问题描述
我的登录表单有一个 Web 视图,我想在触发键盘时自动向上滚动,而不用Text
向上推我的组件。有没有办法让组件忽略键盘,使其保持在键盘下方的底部,同时保留该行为?
以下是我尝试过的代码。它确实将视图向上推,我的文本组件保持在底部,但我在键盘上方留下了一个灰色框。
<KeyboardAvoidingView
style={{flex: 1}
behavior={Platform.OS === 'ios' ? null : 'padding'}
keyboardVerticalOffset={Platform.OS === 'ios' ? 0 : headerHeight - 10}> // if I do -200 it will remove the grey box but the view does not shift when the keyboard is toggled
<ScrollView>
<WebView
automaticallyAdjustContentInsets={false}
style={{flex: 1, alignSelf: 'stretch', width: Dimensions.get('window').width, height: Dimensions.get('window').height},}
source={{ uri }}
/>
<Text style={{position: 'absolute', left: 0, right: 0, textAlign: 'center', bottom: '5%', backgroundColor: 'white'},}>
For more information:{' '}
<Text
style={{ color: 'blue' }}
onPress={() =>
Linking.openURL(redirectURI)
}>
Tap here!
</Text>
</Text>
</ScrollView>
</KeyboardAvoidingView>
我该如何解决?
解决方案
您是否测试过将 KeyboardAvoidingView 放在 ScrollView 中?
推荐阅读
- c++ - 使用 std::mutex 保护 for 循环
- mysql - 从 100 多个表格中获取高分以显示在摘要中
- pytorch - PyTorch DataLoader 为 TorchVision MNIST 添加额外维度
- ubuntu - SFTP 和 SCP 文件传输停止
- php - 如何在laravel中循环子孙
- python - 如何在 AWS Lambda 中导入 .so 文件(共享库)?
- php - 未定义变量:页面(查看:D:\wamp\www\laraangular\resources\views\site\about.blade.php)
- android - 如何在 android 中以与使用 crypto-js 在 Angular 中相同的方式加密数据
- r - 加快 R 中的“for”循环
- java - HttpClient 类 AbstractConnPool 太大了,如何解决?