androidimeoptions

imeOptions="actionSend" not working in material design


I would like to apply send action on my inputText keyboard, however I still see the default arrow, instead send button. I also tried with several devices with different versions and the issue persists.

XML:

 <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/layout"
        style="@style/AppEditText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/dimen_16"
        android:layout_marginEnd="@dimen/dimen_16"
        app:counterMaxLength="9"
        app:helperText="@string/idnow_landing_helper_text"
        app:helperTextEnabled="true"
        app:layout_constraintBottom_toTopOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="parent">

    <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/edit_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/white"
            android:digits="ABCDEFGHIJKLMNOPQRSTUVWXYZ-"
            android:imeOptions="actionSend"
            android:inputType="textCapCharacters"
            android:maxLength="9"
            android:textColor="@color/grayDark"/>
</com.google.android.material.textfield.TextInputLayout>

Activity:

 override fun onCreate(savedInstanceState: Bundle?) {
     ...
      findViewById<EditText>(R.id.edit_text).setOnEditorActionListener { v, actionId, event ->
        return@setOnEditorActionListener when (actionId) {
            EditorInfo.IME_ACTION_SEND -> {
                //do things
                true
            }
            else -> false
        }
    }
 }

Solution

  • The solution is adding:

    android:singleLine="true"

    Result:

    <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/edit_text"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@android:color/white"
                android:imeOptions="actionSend"
                android:inputType="textCapCharacters"
                android:singleLine="true"
                android:digits="ABCDEFGHIJKLMNOPQRSTUVWXYZ-"
                android:maxLength="9"
                android:textColor="@android:color/black"/>