在 Android 上使用带有 React Native 的 KeyboardAvoidView 推送背景图像

问题描述

我想在键盘出现时停止推送背景图像,并且只应向上推送 TextInput 组件和按钮。这适用于 iOS 上的当前代码,但不适用于 Android。我已经尝试过 absoluteimagebackground 位置和 flexheightimagebackground<imagebackground source={require('../../../assets/images/backgroundImage.png')} style={{ // flex: 1,justifyContent: 'center',// height: '100%',position: 'absolute',top: 0,left: 0,bottom: 0,right: 0,}} resizeMode='cover'> <KeyboardAvoidingView style={{ flexGrow: 1 }} enabled behavior={Platform.OS === 'ios' ? 'padding' : 'height'}> <View style={{ flex: 1,justifyContent: 'flex-end',alignItems: 'center',paddingHorizontal: 16,paddingVertical: 1,flexDirection: 'column',height: '100%',}}> <Image source={require('../../../assets/images/logo.png')} style={{ marginBottom: 50 }} resizeMode='contain' /> <SafeAreaView style={{ height: '50%',width: '100%',}}> <View style={{ width: '100%',marginBottom: 10,}}> <TextInput ref={this.classIdRef} style={{ width: '100%',backgroundColor: '#fff',height: 50,borderRadius: 4,marginBottom: 15,paddingHorizontal: 15,}} placeholderTextColor='rgb(218,218,218)' placeholder='Class ID' value={roomId} onChangeText={(text) => this.setRoomId({ roomId: text })} /> <TextInput ref={this.nicknameRef} style={{ width: '100%',marginBottom: 20,}} placeholder='Nickname' placeholderTextColor='rgb(218,218)' value={nickName} onChangeText={(text) => this.setNickName({ nickName: text }) } /> <TouchableOpacity onPress={this.navigatetoClassroomHandler} style={{ backgroundColor: 'rgb(251,158,85)',}} disabled={roomId === '' || nickName === ''}> <Text style={{ fontSize: 18,color: '#fff',fontWeight: 'bold',}}> Attend Class </Text> </TouchableOpacity> </View> </SafeAreaView> </View> </KeyboardAvoidingView> </imagebackground> 但到目前为止没有任何效果。以下是Android上的代码和屏幕截图:

android:windowSoftInputMode="adjustResize"

更新 1: 抱歉,忘了添加截图(我已经在清单文件添加android:windowSoftInputMode="adjustPan"):

enter image description here

enter image description here

使用 wifi_config_t conf; ret = esp_wifi_get_config(ESP_IF_WIFI_STA,&conf); if (ret == ESP_OK) { ESP_LOGI(TAG,"Wifi configuration already stored in flash partition called NVS"); ESP_LOGI(TAG,"%s",conf.sta.ssid); ESP_LOGI(TAG,conf.sta.password); } else { ESP_LOGI(TAG,"Wifi configuration not found in flash partition called NVS."); configure_wifi(); } 时,如下所示:

enter image description here

解决方法

我认为您可以将其添加到您的 AndroidManifest.xml 文件中。

android:windowSoftInputMode="adjustPan"

然后视图不会缩小并且文本输入被推高。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...