4

I am very new in Android apps development and i'm encountering issue with keyboard covering my input fields and I did a search and came to know that I need to add in

android:configChanges="screenSize|locale"

to the xml file. However I do not have the AndroidManifest.xml in my directory. All I have is config.xml which phonegap provided me.

Then I found this https://github.com/phonegap/build/issues/160 but I have no idea where to put this

android:windowSoftInputMode="value1|value2|valueN"

in my config.xml?

Any help is appreciated Thanks in adavance

Amit Prajapati
  • 13,525
  • 8
  • 62
  • 84
Yuan Fen
  • 153
  • 1
  • 3
  • 10

7 Answers7

8

Tried the accepted answer from @markj but it didn't work for me. What DID work was adding this to my config.xml:

<preference name="fullscreen" value="false" />

You do get the "status bar" on top of your app but thats ok with me... Hope that helps

Alex from Jitbit
  • 53,710
  • 19
  • 160
  • 149
3

Why not just use the PhoneGap Build website and upload a zip file? And forget about the manifest file that Amit is talking about. I think he's just making everything more confusing. You need to understand the difference between a local development build and a PhoneGap online build. If you just want to test your app, you don't need to have the local development environment. You can zip your www folder and upload it to the PhoneGap Build service. No command line stuff and no complicated setup. If you want to edit soft keyboard settings, you can edit your config.xml and insert the following:

<preference name="android-windowSoftInputMode" value="stateVisible|adjustResize" />

... or whatever options you want for the windowSoftInputMode.

The documentation is here:

https://build.phonegap.com/docs/config-xml#platform

http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft

Good luck with it.

markj
  • 137
  • 10
  • This preference doesn't seem to exist anymore - https://cordova.apache.org/docs/en/9.x/config_ref/index.html#preference – tremor Aug 24 '19 at 14:21
2

I solved this problem using css media queries.

@media (max-height: 600px) {
  .login-header i {
    display: none;
  }
}

The keyboard resizes the screen and the css above consequently hides 'login-header' when the screen size falls below an arbitrary value (e.g. 600px). This allows the hidden input to come into view.

  • Hi, thanks for contributing to StackOverflow. The question you are answering is old and already answered - we'll be glad if you can give your effort to more pressing questions too. – Mifeet Apr 03 '14 at 14:26
  • 1
    The media-query is not triggered when the keyboard appears! – Rahnzo May 26 '14 at 15:32
2

With

<preference name="fullscreen" value="true" />

I needed to do the following two

a. Use https://github.com/madebycm/AndroidBug5497Workaround/blob/master/AndroidBug5497Workaround.java to ensure that cordova / phonegap can see a change in window height

b. Add the code below to js. This step is required depending upon how the html is written

document.addEventListener('deviceready', onDeviceReady, false);

function onDeviceReady () {
    document.addEventListener('hidekeyboard', onKeyboardHide, false);
    document.addEventListener('showkeyboard', onKeyboardShow, false);
}

function onKeyboardHide() {
    console.log('onKeyboardHide');
}

function onKeyboardShow(e) {
  console.log('onKeyboardShow');
  setTimeout(function() {
    e.target.activeElement.scrollIntoViewIfNeeded()
  }, 500) //needed timeout to wait for viewport to resize
}
0

You have the manifest file in plaforms/android Go ahead and add your option

phonegap run android will add an android build of your phonegap project to the platforms directory, read on http://docs.phonegap.com/en/edge/guide_platforms_android_index.md.html#Android%20Platform%20Guide

DarkLeafyGreen
  • 69,338
  • 131
  • 383
  • 601
  • Hi I get "[phonegap] successfully compiled Android app" but I can't find the apk file anyway on my system. Because I am using an external Android tab to test on and it doesn't support USB, hence I need to send the apk file to my android tab manually. – Yuan Fen Sep 11 '13 at 06:52
  • Before I installed the SDK, when I run "phonegap run android", it will present me with a QR scan code, hence its easy to install to my Android device. But now when I run again after building with local SDK, there isn't any QR code to scan anymore lol. Please help :( – Yuan Fen Sep 11 '13 at 06:57
  • Basically you connect your device with your computer and run "phonegap run android". This will deploy the apk on the device automatically. http://docs.phonegap.com/en/3.0.0/guide_cli_index.md.html – DarkLeafyGreen Sep 11 '13 at 07:06
0

Your AndroidMainFest location : Projectname -> Platform -> android -> AndroidMainFest.xml Your apk location : Project->bin->projectname.apk

set android:windowSoftInputMode="stateVisible|adjustResize" . . . >

Amit Prajapati
  • 13,525
  • 8
  • 62
  • 84
0

Only one solution which worked for my full-screen app, it's to add to the Cordova application ionic-plugin-keyboard plugin

cordova plugin add com.ionic.keyboard

JS code :

// This event fires when the keyboard will hide
window.addEventListener('native.keyboardshow', keyboardShowHandler);

function keyboardShowHandler(e){
    $("body").addClass("keyboardOn");
}

// This event fires when the keyboard will show
window.addEventListener('native.keyboardhide', keyboardHideHandler);

function keyboardHideHandler(e){
    $("body").removeClass("keyboardOn");
}

After that You could adjust the view with CSS.

ref.: https://stackoverflow.com/a/25823491/634275

Community
  • 1
  • 1
Fedir RYKHTIK
  • 9,844
  • 6
  • 58
  • 68
  • Can you post an example of "ajusting the view" with CSS? I think your answer is promising, but it is incomplete. – raider33 May 02 '16 at 01:23