APP运行进入主界面,搜索框获取焦点,软键盘自动弹出,这是一个很不好的用户体验。
根据我遇到的情况,记录下解决方法。
在控件外层的布局中:
android:focusable="true"
android:focusableInTouchMode="true"
在EditText中:
android:imeOptions="actionSearch"
android:singleLine="true"
如: <RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
>
<EditText
android:layout_width="match_parent"
android:layout_height="40dp"
android:hint="搜索"
android:imeOptions="actionSearch"
android:singleLine="true"
/>
</RelativeLayout>