Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EXPERIMENTAL] fitting webview when the software keyboard is displayed. #245

Closed

Conversation

KojiNakamaru
Copy link
Member

cf. #244

@antoniohof
Copy link

antoniohof commented Sep 11, 2017

hi! I have notest that IOS does that automatically. On Android, I was using this solution and so far it is working good:

if (webView.IsKeyboardVisible) {
      keyboardVisible = true;
      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);

			keyboardHeight = Screen.height - Rct.Call<int>("height");
		}
	}
	//Debug.Log ("set keyboard visible " + keyboardHeight);
	webView.SetMargins (0, 0, 0, keyboardHeight);

}else if(keyboardVisible != webView.IsKeyboardVisible){
	webView.SetMargins (0, 0, 0, 0);
}

@KojiNakamaru
Copy link
Member Author

Thanks! I'll later check whether your approach can be applied to the master branch.

@KojiNakamaru
Copy link
Member Author

I've finally implemented #300 based on your code. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants