Android 手机键盘重叠输入
我正在开发一个带有angular meteor的应用程序,每次我聚焦屏幕底部的输入时,键盘都会与之重叠 我尝试将此添加到我的mobile-config.js中,但不起作用:Android 手机键盘重叠输入,android,cordova,meteor,mobile,angular-meteor,Android,Cordova,Meteor,Mobile,Angular Meteor,我正在开发一个带有angular meteor的应用程序,每次我聚焦屏幕底部的输入时,键盘都会与之重叠 我尝试将此添加到我的mobile-config.js中,但不起作用: App.setPreference('fullscreen', false); App.setPreference('android-windowSoftInputMode', 'adjustResize'); 还有我的index.html上的这个meta: <meta name="viewport" content
App.setPreference('fullscreen', false);
App.setPreference('android-windowSoftInputMode', 'adjustResize');
还有我的index.html上的这个meta:
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, target-densitydpi=device-dpi, width=device-width" />
我忘了什么吗?所以你有两个Android选项(iOS对你来说更好一些)。在您的
AndroidManifest.xml
文件中,您将看到第一个文件中的android:windowSoftInputMode
是关于它如何工作的更多信息。这几乎适用于所有情况
此代码位于以下路径下:
── client
├── main.js
// Global variables
let keyboardHeight = 0, originalHeight = 0;
Meteor.startup(() => {
if(Meteor.isCordova){
StatusBar.hide();
// ionic plugin defaults to hide it
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false);
// Android specific events
isAndroid = cordova.platformId == 'android';
if(isAndroid){
// Handle android backbutton
document.addEventListener("backbutton", onBackButtonDown, false);
// Using ionic-plugin-keyboard
window.addEventListener("native.keyboardshow", onShowKeyboard, false);
window.addEventListener("native.keyboardhide", onHideKeyboard, false);
}
}
};
onShowKeyboard = function(e){
let elem = document.activeElement, // Get the focused element
$parent = $(elem).scrollParent(); // Get closest scrollable ancestor (jQuery UI)
// If there is no scrollable parent, no need to continue processing
if($parent.length == 0){
return;
}
// Check if the keyborad type has changed (i.e. from text to number)
if(keyboardHeight != e.keyboardHeight){
keyboardHeight = e.keyboardHeight;
}
// Don't resize if the original height hasn't been reset by onHideKeyboard()
if(originalHeight == 0){
originalHeight = $parent.height();
}
// Subtract keyboard height from parent height + accessory bar height
// Add some class to the parent, to be able to get it back to normal state onHideKeyboard()
$parent.height(originalHeight - keyboardHeight + 50).addClass('adjusted');
// Give the keyboard time to show
setTimeout(function() {
// Scroll to active element
document.activeElement.scrollIntoView({
behavior: "smooth", // or "auto" or "instant"
block: "center" // or "start" or "end"
});
}, 100);
// Unbind DOM object from HTML for garbage collection
elem = null;
$parent.prevObject = null; // To avoid memory leak (for any jQuery DOM object)
$parent = null;
};
onHideKeyboard = function(e){
let s = $('.adjusted').attr('style');
s = s.replace(/height.*;/, '');
$('.adjusted').attr('style', s).removeClass('adjusted');
keyboardHeight = 0;
originalHeight = 0;
};
所以我理解应该是adjustPan而不是adjustResize(不知道为什么人们会推荐这个)。不管怎样,我都试过了,但都不起作用。在Meteor上,我在我的应用程序root-mobile-config.js上找到了。这是我应该换的。在.meteor/local/cordova build中,我找到了config.xml(由带有参数的第一个生成)。使用最后一个,生成了platforms/android/AndroidManifest.xml中的一个,但是我在最后一个上找不到在第一个上添加的对此参数的任何引用。我还尝试将此属性直接添加到AndroidManifest.xml中(我知道我不应该编辑此属性,这只是一次尝试)但该应用程序没有compile@DanielRodriguez我对Meteor不太熟悉-是的,您应该直接将此属性添加到AndroidManifest.xml文件中,尽管我不知道Meteor如何处理它,在普通的Cordova应用程序上,您必须编辑config.xml,而此应用程序生成AndroidManifest.xml。在Meteor上,您不必编辑这两个选项中的任何一个,只需编辑mobile-config.js,这一个生成config.xml(这一个是另一个)。因此,编辑这3个文件中的任何一个我都可以得到任何修复这是我想要的修复,但这是使用React:你找到解决方案了吗??我有同样的设置,并渴望使它工作!找不到任何东西,szI已经为它做了一个工作黑客解决方法,如果你感兴趣,请让我知道在这里发布它。当然,请让我知道在下面找到我的答案