Created
October 26, 2020 07:26
-
-
Save matthewmorrone/1d96c54f066833dc7f3222e596b9cf66 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void makeKeyboardTransparent(InputMethodService service) { | |
try { | |
View decorView = service.getWindow().getWindow().getDecorView(); | |
final int viewId = fetchInternalRId("fullscreenArea"); | |
View fullscreenArea = decorView.findViewById(viewId); | |
if (fullscreenArea != null) { | |
modifyView(fullscreenArea); | |
return; | |
} | |
} catch (Exception e) { | |
} | |
try { | |
Class<?> superClass = service.getClass().getSuperclass(); | |
Field fullscreenAreaField = superClass.getDeclaredField("mFullscreenArea"); | |
fullscreenAreaField.setAccessible(true); | |
View fullscreenArea = (View) fullscreenAreaField.get(service); | |
if (fullscreenArea != null) { | |
modifyView(fullscreenArea); | |
} | |
} catch (Exception e) { | |
} | |
} | |
private static void modifyView(View fullscreenArea) { | |
fullscreenArea.setBackgroundColor(Color.TRANSPARENT); | |
} | |
private static int fetchInternalRId(String name) throws Exception { | |
Class<?> rIdClass = Class.forName("com.android.internal.R$id"); | |
return rIdClass.getDeclaredField(name).getInt(rIdClass); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment