FloatingSearchView 是浮动搜索视图,实现了一个浮动的搜索框和搜索建议。
<com.arlib.floatingsearchview.FloatingSearchView android:id="@+id/floating_search_view" android:layout_width="match_parent" android:layout_height="match_parent" app:floatingSearch_searchBarMarginLeft="@dimen/search_view_inset" app:floatingSearch_searchBarMarginTop="@dimen/search_view_inset" app:floatingSearch_searchBarMarginRight="@dimen/search_view_inset" app:floatingSearch_showMenuAction="true" app:floatingSearch_searchHint="Search..." app:floatingSearch_voiceRecHint="Say something..." app:floatingSearch_showSearchHintWhenNotFocused="true" app:floatingSearch_showVoiceInput="true" app:floatingSearch_showOverFlowMenu="true" app:floatingSearch_hideOverflowMenuWhenFocused="true" app:floatingSearch_showSearchKey="false" app:floatingSearch_dismissOnOutsideTouch="true" app:floatingSearch_menu="@menu/menu_main"/> mSearchView.setOnQueryChangeListener(new FloatingSearchView.OnQueryChangeListener() { @Override public void onSearchTextChanged(String oldQuery, final String newQuery) { //get suggestions based on newQuery //pass them on to the search view mSearchView.swapSuggestions(newSuggestions); } });