问题描述
我想在键盘出现时停止推送背景图像,并且只应向上推送 TextInput 组件和按钮。这适用于 iOS 上的当前代码,但不适用于 Android。我已经尝试过 absolute
的 imagebackground
位置和 flex
的 height
和 imagebackground
的 <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"
):
使用 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();
}
时,如下所示:
解决方法
我认为您可以将其添加到您的 AndroidManifest.xml 文件中。
android:windowSoftInputMode="adjustPan"
然后视图不会缩小并且文本输入被推高。