androidandroid-edittextimeoptions

Android: imeOptions doesn't work despite using maxLines and inputType


I want the soft keyboard in my app to show Done when clicking on a particular EditText. This is how it looks

<EditText
     android:id="@+id/code_editText"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_below="@id/enter_code_textView"
     android:layout_marginStart="@dimen/margin_25dp"
     android:layout_marginLeft="@dimen/margin_25dp"
     android:layout_marginTop="@dimen/margin_12dp"
     android:layout_marginEnd="@dimen/margin_25dp"
     android:layout_marginRight="@dimen/margin_25dp"
     android:background="@drawable/edittext_background"
     android:maxLines="1"
     android:inputType="text"
     android:imeOptions="actionDone"
     android:textColor="@color/black"
     android:textCursorDrawable="@null"
     android:textSize="16sp" />

But this doesn't work. The soft keyboard enter key text doesn't change at all. I tried this on multiple devices, one Oreo and one KitKat. I also tried using singleLine attribute but that doesn't work too. What am I missing here? Thanks in advance!


Solution

  • There's no way to force the soft keyboard to show any key, not even the imeOptions. The keyboard app uses that as a hint- it doesn't have to honor it. And remember that every different keyboard will make different choices on whether or not to honor it. And that there is no such thing as the "default keyboard" as many OEMs replace it. Basically, you can set the imeOptions and hope it works, but there's no way to force it to work across all devices and keyboard apps.