by MiguelCatalan

MiguelCatalan / MaterialSearchView

Cute library to implement SearchView in a Material Design Approach

3.7K Stars 625 Forks Last release: almost 5 years ago (vv1.3.1) Apache License 2.0 66 Commits 7 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:


Cute library to implement SearchView in a Material Design Approach. Works from Android API 14 (ICS) and above.

sample sample

Get it on Google Play

Native version

Maybe it would be useful to take a look into the new official approach


Add the dependencies to your gradle file:

    dependencies {
        compile 'com.miguelcatalan:materialsearchview:1.4.0'
Add MaterialSearchView to your layout file along with the Toolbar (Add this block at the bottom of your layout, in order to display it over the rest of the view):

    < android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="@color/theme_primary"></>

    <com.miguelcatalan.materialsearchview.materialsearchview android:id="@+id/search_view" android:layout_width="match_parent" android:layout_height="wrap_content"></com.miguelcatalan.materialsearchview.materialsearchview>

Add the search item into the menu file:

Add define it in the onCreateOptionsMenu: ```java @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(, menu);
    MenuItem item = menu.findItem(;

return true;


Set the listeners:

```java MaterialSearchView searchView = (MaterialSearchView) findViewById(; searchView.setOnQueryTextListener(new MaterialSearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { //Do some magic return false; }

        public boolean onQueryTextChange(String newText) {
            //Do some magic
            return false;

    searchView.setOnSearchViewListener(new MaterialSearchView.SearchViewListener() {
        public void onSearchViewShown() {
            //Do some magic

        public void onSearchViewClosed() {
            //Do some magic

Use VoiceSearch

Allow/Disable it in the code:

    searchView.setVoiceSearch(true); //or false
Handle the response: ```java @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == MaterialSearchView.REQUESTVOICE && resultCode == RESULTOK) { ArrayList matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); if (matches != null && matches.size() > 0) { String searchWrd = matches.get(0); if (!TextUtils.isEmpty(searchWrd)) { searchView.setQuery(searchWrd, false); } }
    super.onActivityResult(requestCode, resultCode, data);
# Add suggestions
**Define them in the resources as a *string-array*:**

Add them to the object:


Style it!


We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.