Skip to content

Bug with android margin adjustment for keyboard. #926

Closed

Description

@pinnakkkk

Hi there! I have been using the Unity WebView plugin in my project, and overall it has been a great tool. However, I have encountered an issue with the Android margin adjustment for the keyboard, which is not working as stated in the issue #300.

Expected Behavior:
When an input field receives focus and the keyboard appears, the WebView content should be adjusted to ensure the input field remains visible without being obscured by the keyboard.

Actual Behavior:
The Android margin adjustment for the keyboard does not seem to work as intended. The WebView content does not properly adjust, resulting in the keyboard partially or completely obscuring the focused input field.

Additional Information:
Unity version: 2021.3.0f1
Device tested: Redmi k20 (Android 11)
Unity Player settings: fullscreen enabled

Thank you for your effort in developing this plugin. It has been a valuable addition to my project, and I appreciate your dedication to maintaining it.

Please let me know if there are any further details or information I can provide to help resolve this issue.

Activity

  1. pinnakkkk commented on May 15, 2023

    @pinnakkkk
    Author

    Update: upon further investigating this piece of code is always false even if the keyboard is shown.

    /// Called from Java native plugin to set when the keyboard is opened
    	public void SetKeyboardVisible(string pIsVisible)
    	{
    		Debug.Log("SetKeyboardVisible: " + pIsVisible);
    		if (BottomAdjustmentDisabled())
    		{
    			return;
    		}
    		bool isKeyboardVisible0 = mIsKeyboardVisible;
    		mIsKeyboardVisible = (pIsVisible == "true");
    		if (mIsKeyboardVisible != isKeyboardVisible0 || mIsKeyboardVisible)
    		{
    			SetMargins(mMarginLeft, mMarginTop, mMarginRight, mMarginBottom, mMarginRelative);
    		}
    	}
    
  2. KojiNakamaru commented on May 16, 2023

    @KojiNakamaru
    Member

    Thank you for reporting and investigating the issue. I modified the keyboard detection logic in #928 and updated binaries. Could you please try the latest?

  3. pinnakkkk commented on May 17, 2023

    @pinnakkkk
    Author

    Absolutely! thankyou so much!

  4. wa1kb0y commented on May 26, 2023

    @wa1kb0y

    Hello, i tried it and it seems issue is still there, i tried to import unity-webview.unitypackage in new clean project to test. @pinnakkkk does fix work for you?

  5. x-ishi commented on Jun 21, 2023

    @x-ishi

    こちらの問題について対応中になりますでしょうか。
    書き込み時点のmasterブランチのunity-webview.unitypackageをインポートして確認しましたが、同じように入力エリアがキーボードに隠れる現象が発生するようでした。
    確認環境
    ・Unity2020.3.43f1
    ・google pixel3(android os12)

  6. KojiNakamaru commented on Jun 21, 2023

    @KojiNakamaru
    Member

    @x-ishi
    その後、特に調査は進めておりませんが、テストがしやすいよう、改めてサンプルを整えました。キーボード周りについてWebViewObject.csにXXXで始まるログを仕込んであります。

    https://github.com/gree/unity-webview/tree/example-for-926/sample
    028f13f...51ef618

    OSCAL Pad 8 (Android 11)やPixel 4a (Android 12)で確認する限りでは、再現しないようです。なお、おそらく該当しないだろうと思いますが、

    9c53747

    により、フルスクリーンでない場合や、ポートレイトとランドスケープの両方をサポートする場合は、この調整が無効になっています。

  7. x-ishi commented on Jun 22, 2023

    @x-ishi

    ご確認ありがとうございます。
    ポートレイトの設定をしたところ問題なく動作いたしました。

  8. x-ishi commented on Jun 23, 2023

    @x-ishi

    Project Settings > Resolution and Presentatin > Hide Navigation Bar
    サンプルについて確認していまして上記のチェックをオフにすると調整が無効になるようでした。

    チェックをオフにした上で動作するように改善していただくことは可能でしょうか。

  9. KojiNakamaru commented on Jun 23, 2023

    @KojiNakamaru
    Member

    @x-ishi #938 でUNITYWEBVIEW_ANDROID_FORCE_MARGIN_ADJUSTMENT_FOR_KEYBOARDを定義した場合に、常に調整を行うようにしました。 #729 の問題は、現時点の手元の端末で試した限りは起こらないようです。

    なお、別件ですが、 #890 (comment) を参考にさせていただいて、最新のバイナリには #937 も含まれています。

  10. x-ishi commented on Jun 29, 2023

    @x-ishi

    @KojiNakamaru
    ご対応ありがとうございます。
    アプリに組み込んで確認しまして大丈夫そうでした。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions