- Home /
Android Keyboard height not working
https://forum.unity.com/threads/keyboard-height.291038/
using(AndroidJavaClass UnityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
{
AndroidJavaObject View = UnityClass.GetStatic<AndroidJavaObject>("currentActivity").Get<AndroidJavaObject>("mUnityPlayer").Call<AndroidJavaObject>("getView");
using(AndroidJavaObject Rct = new AndroidJavaObject("android.graphics.Rect"))
{
View.Call("getWindowVisibleDisplayFrame", Rct);
return Screen.height - Rct.Call<int>("height");
}
}
the code shows me the screen height (rect) as 2240 and Screen.height as 2240 too, which returns 0 to me. Unity 2020.1.4f1 and android 10. i use Swift Keyboard, but it does not matter because the google keyboard also does not work. Is there any new way? I wonder if the problem is the native input field, but it doesn't work on normal ones either.
I'm using native inputs: https://github.com/mopsicus/UnityMobileInput
yes, the plugin shows the size of the keyboard but unfortunately it is not always correct.Unless someone could add a function to the plug-in to get the size of the keyboard, not only at opening but in real time?
Your answer
Follow this Question
Related Questions
How can I detect Keyboard Events? 4 Answers
Keyboard detector 0 Answers
rotate an object with keyboard 1 Answer