android:focusable=“true”
android:focusableInTouchMode=“true”
EditText中加入
android:imeOptions=“actionSearch”
就完事了!
举例
–
假设一个Toolbar布局,输入框是EditText,那么就在父布局中LinearLayout或者在android.support.v7.widget.Toolbar中加入上面的两句,然后再EditText中加入android:imeOptions=“actionSearch”
<android.support.v7.widget.Toolbar
android:id=“@+id/toolbar”
android:layout_width=“match_parent”
android:layout_height=“50dp”
android:background=“#ff534c”
android:fitsSystemWindows=“true”
android:focusable=“true” //父布局中加入这一句
android:focusableInTouchMode=“true” //父布局中加入这一句
android:scrollbarSize=“13sp”>
<LinearLayout
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:background=“@drawable/head_search”
android:orientation=“hori