0

I've tried the Android documentation method and some answers from StackOverflow. Actually, it works well when I use SearchView, not in ActionBar menu. Here is code.

styles.xml

<style name="AppTheme.SearchView" parent="Widget.AppCompat.SearchView">
    <item name="searchIcon">@drawable/ic_icon_1</item>
    <item name="closeIcon">@drawable/ic_icon_2</item>
</style>

<style name="AppTheme" parent="Theme.AppCompat.Light">
    <item name="searchViewStyle">@style/AppTheme.SearchView</item>
</style>

my_menu.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto">

    <item
        android:id="@+id/item_search"
        android:title="@string/search"
        app:actionViewClass="android.support.v7.widget.SearchView"
        app:showAsAction="always"/>
</menu>

I also tried to set searchViewStyle field in ActionBar's style but again no result.

Vukašin Manojlović
  • 3,717
  • 3
  • 19
  • 31
haksist
  • 229
  • 2
  • 5
  • 17

1 Answers1

0

i suggest you to look at my answer I gave here to style your own SearchBar.

I can't get the reason but I couldn't style Google's default SearchBar so I had to create my own Search bar.

Here's how I did:

Styling Search View on Android (min21) -- Styling Search View on Android (min21)

If you want to implement an InstantSearch algorithm follow this great author and his project (look at the accepted answer):

How to filter a RecyclerView with a SearchView -- How to filter a RecyclerView with a SearchView

If you need further help just leave a comment. If the answer helped also upvote my answer :P

UPDATE: Here's Google's implementation of the Search View, just to give you more information: https://developer.android.com/guide/topics/search/search-dialog.html

Have a nice day :)