【问题标题】:SearchView: Keyboard not show button DoneSearchView:键盘不显示按钮完成
【发布时间】:2017-11-16 08:46:50
【问题描述】:

安卓 4.3.

这里是sn-p:

 <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" />

我希望在单击 SearchView 时显示带有 完成 按钮的键盘。所以我设置了android:imeOptions="actionDone"。但这无济于事:

这里的结果:

【问题讨论】:

  • 这个设置没有帮助。显示玻璃按钮。
  • 您需要添加 android:maxLines="1" 并使其成为 EditText 而不是 SearchView
  • @KingofMasses android:singleLine="true" 已弃用
  • 使用 android:maxLines="1" 而不是 android:singleLine="true"
  • 在我的例子中我使用了 android:maxLines="1" 但它没有帮助

标签: android searchview


【解决方案1】:

试试这个

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

【讨论】:

  • 试试这个答案。而且 singleLine 已被弃用,但它仍然很重要
  • 实际上我正要给出相同的答案,但看到的却是相同的,我很感激 -> 继续编码并继续提供帮助
  • @BabulPatel 喜欢编码
猜你喜欢
  • 1970-01-01
  • 2012-11-13
  • 1970-01-01
  • 1970-01-01
  • 2010-10-09
  • 1970-01-01
  • 2017-04-19
  • 1970-01-01
  • 2015-04-06
相关资源
最近更新 更多