Managing Keyboard on Webview

Webview itself is a pain to manage in Android. Keyboard is another pain to manage. I’ll show you how to customize keyboard in webview here.

To view more about managing webview, you could refers to my previous blog. Here, I’m focusing the Keyboard part.

Background

Unlike most of other views in your App, the native Keyboard in Android is not really part of your App. Hence you have limited control over it. It’s usually provided together with EditText, where you could define your keyboard through the XML of your EditText.

However for Webview, those are not possible. Hence to manage Keyboard, you would need to customized the WebView.

Customizing WebView

For customizing any view, you could refers to my previous blog.

1. Inheriting from WebView

Similarly for WebView, you do the same thing by inheriting from WebView and overload the constructors as below

class MyWebView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : WebView(context, attrs, defStyleAttr) {
// Other details code here.
// (as per section 2 and 3 below)
}

2. Customizing…

--

--