I am working on an phonegap app for a Samsung Galaxy Tab 3. When this application is in full screen mode, the softkeyboard hides the text input fields and it's impossible to scroll the page to see the content. how could I fix the problem?
Explanation: The fullscreen format is a display format that modifies the original movie to fit the aspect ratio of your TV or another display. When a movie is displayed in the full screen format, a notice is shown indicating that the movie is formatted to fit your screen.
After spending a day trying almost every possible solution in this website, nothing worked for me. At the end I was able to find a work around based on the following two proposed solutions:
https://stackoverflow.com/a/19494006/1435991
this link shows a workaround to fix the problem for an android app; however I don't have any experience working in android, so the question is: how to include this peace of code in a Phonepap project?.
https://stackoverflow.com/a/18610405
This link suggests specifically a solution for phonegap, which did not work for me, but more important gave an idea of how I could add custom android code on a phonegap project.
SOLUTION
1- Create the following class(as indicate in first link) in your phonegap project:
package com.test.android;
import android.app.Activity;
import android.graphics.Rect;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
public class AndroidBug5497Workaround {
// For more information, see https://code.google.com/p/android/issues/detail?id=5497
// To use this class, simply invoke assistActivity() on an Activity that already has its content view set.
public static void assistActivity (Activity activity) {
new AndroidBug5497Workaround(activity);
}
private View mChildOfContent;
private int usableHeightPrevious;
private FrameLayout.LayoutParams frameLayoutParams;
private AndroidBug5497Workaround(Activity activity) {
FrameLayout content = (FrameLayout) activity.findViewById(android.R.id.content);
mChildOfContent = content.getChildAt(0);
mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
public void onGlobalLayout() {
possiblyResizeChildOfContent();
}
});
frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams();
}
private void possiblyResizeChildOfContent() {
int usableHeightNow = computeUsableHeight();
if (usableHeightNow != usableHeightPrevious) {
int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight();
int heightDifference = usableHeightSansKeyboard - usableHeightNow;
if (heightDifference > (usableHeightSansKeyboard/4)) {
// keyboard probably just became visible
frameLayoutParams.height = usableHeightSansKeyboard - heightDifference;
} else {
// keyboard probably just became hidden
frameLayoutParams.height = usableHeightSansKeyboard;
}
mChildOfContent.requestLayout();
usableHeightPrevious = usableHeightNow;
}
}
private int computeUsableHeight() {
Rect r = new Rect();
mChildOfContent.getWindowVisibleDisplayFrame(r);
return (r.bottom - r.top);
}
}
This class can be placed in this location in your project: (I was not able to load an image in this forum, I need at lease 10 reputation). Find the image sample in this url:
2- Any time you create a phonegap project you get a class called your_project_name.java. In my case it is test1.java. Edit the class and add the following sentence in method onCreate:
AndroidBug5497Workaround.assistActivity(this);
Your code should look like this:
public class test1 extends DroidGap { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set by in config.xml super.loadUrl(Config.getStartUrl()); //super.loadUrl("file:///android_asset/www/index.html") AndroidBug5497Workaround.assistActivity(this); } }
3- This fixed the problem in my app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With