Search code examples
androidandroid-edittextfocusandroid-keypad

How to hide keypad when editText is in focus


I want the editText box to be click-able so the user can scroll through the text, but I do not want the keyboard to appear. I have tried all these but they do not do what I want:

In XML:

android:editable="false"
android:windowSoftInputMode="stateAlwaysHidden"
android:inputType="none"

This disables it:

editText.setInputType(EditorInfo.TYPE_NULL); 

This only works on API 21 and above:

editText.setShowSoftInputOnFocus(false);

Solution

  • Try this

    <EditText
            android:id="@+id/et_file_url"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="none"
            android:lines="1"
            android:textIsSelectable="true" />