android - 单击它之前的 SearchView 查询提示

标签 android android-studio

我有一个搜索 View 和一个查询提示属性。但是,提示仅在单击搜索 View 后出现。有没有办法让它在被点击之前出现?

<SearchView
        android:id="@+id/searchView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/textView4"
        android:layout_marginBottom="14dp"
        android:layout_marginTop="30dp"
        android:queryHint="Search" />

enter image description here

enter image description here

我看到另一个类似查询的SO问题,但没有解决。这就是我再次提问的原因。

最佳答案

使用这个 XML:

android:queryHint="hint"
app:queryHint="hint"
app:defaultQueryHint="hint"
android:iconifiedByDefault="false"  // this line
app:iconifiedByDefault="false"

用于 {android.support.v7.widget.SearchView} 的应用

关于android - 单击它之前的 SearchView 查询提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33566780/

相关文章:

android - Flutter Mapbox 构建一直失败( list 合并失败)

android - 添加注解处理器时,Android Studio会引发重复的类错误

Android Studio 1.4 gradle 在构建 baseGameUtils 时失败

android - FFmpeg 错误输出文件 #0 不包含任何流

android - 录制视频时摩托罗拉 DROID RAZR 的相机问题

android WebView 停止 Flash 插件 onPause

android - gradle 如何确定从哪个存储库安装?

android - 在 Ubuntu 18.04 上 react 原生 Android 模拟器错误

android - 三星 Galaxy S 中的 Root 模式

Android Studio 错误 "Installation did not succeed. The application could not be installed. Installation failed due to: ' null'"