0

I have an app that is basically just a WebView. I want to only accept input from a hardware keyboard. I haven't figured out a way to hide/disable the Android soft keyboard without also disabling the hard keyboard as well.

This code strangely allows the text fields to be focused and the cursor shows in the field, however I cannot type any characters:

<WebView
   android:id="@+id/webview"
   android:focusable="false"
   android:focusableInTouchMode="false"
   android:layout_width="match_parent"
   android:layout_height="match_parent"/>

I've tried many things but nothing seems to work. I'm feeling like this is not possible to do but it sounds like something that should be.

Thanks in advance

Aaron McKellar
  • 597
  • 4
  • 8
  • 20

1 Answers1

0

Please see Android Team answer here:

Disable SoftKeyboard inside a WebView

Add following code in main(parent) layout in your layout.xml

android:descendantFocusability="blocksDescendants"

and set following property in your webview

android:focusable="false" 
android:focusableInTouchMode="true"

If that also blocks your hardware keyboard then this other method should work for you:

How to hide keyboard when user clicks on textbox in webview android

Community
  • 1
  • 1
Andrew Fox
  • 96
  • 6
  • Tried the first solution before. Doesn't work, it disables the input boxes so they can't be focused at all. I've tried some solutions in the link posted with no luck but I will run through more and see if I can get it to work with one of those and report back. Thanks – Aaron McKellar Oct 19 '19 at 00:38
  • @AaronMcKellar how about this solution of detecting when the software keyboard opens and then hiding it? https://stackoverflow.com/a/33657024/4318658 – Andrew Fox Oct 19 '19 at 04:06