ZeroCool83 ZeroCool83 - 8 months ago 60
Android Question

Android: How do I change the style of recent queries list in a SearchView?

I implemented a recent queries Content Provider for my Searchable Configuration and it works, but how do I change the style of the list?

It came with white text on light background, I'd like to change at least the color of text.

Thank you for your help!


Use the suggestionRowLayout attribute from the AppCompat Lollipop’s SearchView API. For a complete list of attributes see this post from Android Developers Blog.

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

<style name="AppTheme.SearchView" parent="@style/Widget.AppCompat.SearchView">        
    <!-- Layout for query suggestion rows -->
    <item name="suggestionRowLayout">@layout/abc_search_dropdown_item_icons_2line</item>

If you have problems with the suggestionRowLayout attribute you can try the solution Alternatively, you could try to use the old searchView* theme attributes as you can see in this post.