androidsearchview

SearchView: Keyboard not show button Done


android 4.3.

here snippet:

 <android.support.v7.widget.SearchView
        android:id="@+id/searchView"
        style="@style/Widget.AppCompat.SearchView.ActionBar"
        android:layout_width="0dp"
        android:layout_height="30dp"
        android:layout_marginEnd="20dp"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:layout_marginStart="20dp"
        android:background="@drawable/search_view_bg"
        android:imeOptions="actionDone"
        android:maxLines="1"
        android:inputType="text"
        android:theme="@style/SearchViewTheme"
        app:defaultQueryHint="@null"
        app:layout_constraintLeft_toLeftOf="@+id/searchViewContainer"
        app:layout_constraintRight_toRightOf="@+id/searchViewContainer"
        app:layout_constraintTop_toTopOf="@+id/searchViewContainer"
        app:searchHintIcon="@null" />

I want when click on SearchView to show keyboard with Done button. So I set android:imeOptions="actionDone". But it not help:

Here result:

keyboard


Solution

  • Try this

    searchview.setImeOptions(EditorInfo.IME_ACTION_DONE);
    searchview.setSingleLine(true);