Search code examples
androidandroid-studiocustom-keyboardandroid-keypad

Show keyboard in password mode without styling the EditText


I need the keyboard to be shown in the mode similar to the password input type field, but i dont want to specifically set it to that mode for all the Edittext's in the xml. My required type is somewhat similar to the image here: Sample Keyboard Pattern Basically, I want to disable the whole bar that contains the speech and auto complete in it, but want my EditText to display the same mode as normal text field.


Solution

  • Add the following attributes to your EditText layout:

    android:inputType="textFilter"
    android:privateImeOptions="nm"
    

    Additionally, add this in onCreate method of MainActivity:

    InputMethodManager imm = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
    

    For reference, take a look at this.