答案 0 :(得分:3)
这是SearchView的一些自定义 查看文档http://developer.android.com/guide/topics/search/search-dialog.html
Actvity就像这样声明了
<activity android:name=".SearchableActivity"
android:launchMode="singleTop" >
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable"/>
</activity>
和SearchView xml
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/search_label"
android:hint="@string/search_hint"
android:voiceSearchMode="showVoiceSearchButton|launchRecognizer" >
</searchable>
您还需要覆盖onSearchRequested
@Override
public boolean onSearchRequested() {
Bundle appData = new Bundle();
appData.putBoolean(SearchableActivity.JARGON, true);
startSearch(null, false, appData, false);
return true;
}
答案 1 :(得分:1)
一些很棒的库提供了你想要的搜索视图,例如:
Floating Search View
还有更多:
https://github.com/lapism/SearchView
https://github.com/Quinny898/PersistentSearch