takahirom / webview-in-coordinatorlayout

248 stars 71 forks source link

When selecting a text input/field inside the WebView, the soft keyboard is never shown. #2

Closed blinkmacalahan closed 8 years ago

blinkmacalahan commented 8 years ago

This could possibly be a duplicate of Issue #1, but I'm creating a separate issue just in case.

When tapping the text input/field the input got focus and a cursor appeared; however, Android's soft keyboard never appeared. After hacking around and through trial and elimination, I found that removing all the code this class had and only using the constructors provided that the issue still existed. So I looked at Android's WebView constructor with 2 parms and noticed it passes com.android.internal.R.attr.webViewStyle for the defStyleAttr parameter. I took a shot in the dark and tried passing android.R.attr.webViewStyle as the defStyleAttr parm instead of 0 and now the soft keyboard appears.

So the fix is to remove this constructor:

    public NestedWebView(Context context, AttributeSet attrs) {
            this(context, attrs, 0);
    }

and instead use this one:

    public NestedWebView(Context context, AttributeSet attrs) {
            this(context, attrs, android.R.attr.webViewStyle);
    }

I have no idea why this fixes the issue. I would have to take a closer look at what android.R.attr.webViewStyle declares.

takahirom commented 8 years ago

I will look at it later.

takahirom commented 8 years ago

Sorry for late reply. webViewStyle equals following. So your suggestion is probably good! So, I have applied it to this project.

        <item name="focusable">true</item>
        <item name="focusableInTouchMode">true</item>
        <item name="scrollbars">horizontal|vertical</item>