I'm trying to style the SearchView widget using the new AppCompat v21, but I'm facing some problems. No matter what layout I set on "suggestionRowLayout" attribute, it does nothing at all. The suggestion dropdown list of the SearchView remains the same way.
Other problem that I'm having is when the "accent color" is the same color as the "primary color", in the searchview is impossible to distinguish where is the caret. Do you know how can I change the accent color in the SearchView to only be applied there? I've found that Play Music has the same problem.
I'm following the guide from Android Developers blog:
http://android-developers.blogspot.com.es/2014/10/appcompat-v21-material-design-for-pre.html
My issue was that the Searchview was not of type android.support.v7.widget.SearchView, therefore all styling did not apply
According to what I have seen in the SearchView source
suggestionRowLayout
resource value in SearchView occurs when retrieving the attributes for the SearchView and in the methodgetSuggestionRowLayout()
. On the other hand the implementation of SuggestionAdapter of v7 library is inflatingabc_search_dropdown_item_icons_2line
.Idea for a workaround:
Try referencing different layout with help of
refs.xml
. Make sure you keep same ids for views as inabc_search_dropdown_item_icons_2line
suggestionsRowLayout
wasn't working for me either.In my case, I just needed to change the background color of each row and the text color.
So I just modified the layout of the View returned from
newView()
in my SuggestionsAdapter:search_item.xml
You could of course set the background to a selector drawable for click highlights.