2017-04-14 2 views
1

각도 유성을 사용하는 앱을 개발 중이며 화면 하단에있는 입력에 초점을 맞출 때마다 키보드가 겹칩니다.모바일 키보드에서 입력이 겹쳐졌습니다.

는 내 모바일 config.js이 추가 시도했지만 작동하지 않습니다

App.setPreference('fullscreen', false); 
App.setPreference('android-windowSoftInputMode', 'adjustResize'); 

또한이 메타를 내 index.html을에 :

<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, target-densitydpi=device-dpi, width=device-width" /> 

내가 뭔가를 잊고 건가요?

+0

는이에 대한 해결책에 도달했습니다 ?? 나는 동일한 설정을 가지고 있으며, 작동하도록 만들기 위해 죽어 가고있다! – Roshdy

+0

아직 아무것도 찾을 수 없습니다. sz –

+0

나는 그것에 대해 작동 해킹 된 해결 방법을 만들었습니다. 흥미가 있다면, 여기에 게시하도록 알려주세요. – Roshdy

답변

0

그래서 Android에는 두 가지 옵션이 있습니다 (iOS가 더 멋지게 처리합니다). AndroidManifest.xml 파일에 처음으로 <activity> 태그 안에 android:windowSoftInputMode이 표시됩니다. 그러면 키보드가 화면과 상호 작용하는 방식이 조정됩니다. Here은 어떻게 작동하는지에 대한 자세한 정보입니다.

+0

그래서 나는 adjustPan 대신 adjustRanize (사람들이 왜 이것을 추천하는지 확실하지 않다)라고 이해한다. 나는 어쨌든 둘 다 시도했지만 어느 쪽도 일하지 않습니다. Meteor에서 내 앱 루트 인 mobile-config.js가 있습니다. 이것은 내가 바꿔야 만하는 것입니다. .meteor/local/cordova-build에서 config.xml (매개 변수가있는 첫 번째 항목에서 생성)을 찾았습니다. 마지막으로 platform/android/AndroidManifest.xml 파일이 생성되었지만이 마지막 매개 변수에 대한 참조는 처음에 추가되었습니다. –

+0

또한이 속성을 AndroidManifest에 직접 추가하려고 시도했습니다. xml (나는 이것을 편집해서는 안된다는 것을 알았지 만 그것은 단지 시도였다.) 그러나 앱은 컴파일되지 않는다. –

+0

@DanielRodriguez Meteor에 익숙하지 않다. - 네,이 속성을 AndroidManifest.xml에 직접 추가해야합니다. 파일, 비록 Meteor가 어떻게 처리하는지 모르겠다. –

1

이것은 거의 모든 상황에서 저에게 효과적입니다.

이 코드는 경로 아래 :

── 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; 
};