How to style Android SearchView like in Google Play Store app? How to style Android SearchView like in Google Play Store app? android android

How to style Android SearchView like in Google Play Store app?


You might try to deep dive into this project:

https://android.googlesource.com/platform/packages/apps/Dialer/

For Lollipop or Marshmallow, or N it has a SearchEditTextLayout which is what you need:

Advantage

  • a code made by Google, not third party.


You have to use this Custom Implementation of SearchView.

https://github.com/Quinny898/PersistentSearch

Android Studio:

Add the Sonatype repository if you have not already:

maven {        url "https://oss.sonatype.org/content/repositories/snapshots"    }

Import it as a dependency:

compile 'com.quinny898.library.persistentsearch:library:1.1.0-SNAPSHOT'

In your layout:

<com.quinny898.library.persistentsearch.SearchBox        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:id="@+id/searchbox"        />

Output :

enter image description here


I myself was trying to build this. Ended up just making the search button an ImageButton. a click on this would Trigger a Fragment to be added on top which would contain an Edittext inside an layout made to look like this. and this Fragment consisted of a listview below this searchbox to show suggestions.

Tip: Keep the Fragment's rootlayout without any background and set clickable to true to achieve best results with a transparent pane