Commit 4e6f219941a54335555b2ce4945e79c62210db50

Sam Lantinga 2016-10-01T15:14:48

Fixed bug 3065 - Screen is flickering during closing on-screen keyboard on Android Deve When I'm trying to close on-screen keyboard using SDL_StopTextInput() function by touching the screen (SDL_FINGERUP or SDL_FINGERDOWN event), the screen is flickering. It is white for a while. Note that it usually works without problems when I use phone's "back" button. I noticed flickering occasionally too, but not that often. Philipp Wiesemann The attached patch maybe fixes the flicker but not the actual fault causing it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/android-project/src/org/libsdl/app/SDLActivity.java b/android-project/src/org/libsdl/app/SDLActivity.java
index 7e30073..15b799c 100644
--- a/android-project/src/org/libsdl/app/SDLActivity.java
+++ b/android-project/src/org/libsdl/app/SDLActivity.java
@@ -369,7 +369,10 @@ public class SDLActivity extends Activity {
                 break;
             case COMMAND_TEXTEDIT_HIDE:
                 if (mTextEdit != null) {
-                    mTextEdit.setVisibility(View.GONE);
+                    // Note: On some devices setting view to GONE creates a flicker in landscape.
+                    // Setting the View's sizes to 0 is similar to GONE but without the flicker.
+                    // The sizes will be set to useful values when the keyboard is shown again.
+                    mTextEdit.setLayoutParams(new AbsoluteLayout.LayoutParams(0, 0, 0, 0));
 
                     InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
                     imm.hideSoftInputFromWindow(mTextEdit.getWindowToken(), 0);