Skip to content

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

Closed
KojiNakamaru wants to merge 1 commit into
masterfrom
experimental/android_fit_for_softkeyboard
Closed

KojiNakamaru wants to merge 1 commit into
masterfrom
experimental/android_fit_for_softkeyboard

Conversation

@KojiNakamaru

Copy link
Copy Markdown
Member

cf. #244

@antoniohof

antoniohof commented Sep 11, 2017 •

Copy link
Copy Markdown

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
Copy Markdown
Member Author

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

@KojiNakamaru

Copy link
Copy Markdown
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