ZeroCool83 ZeroCool83 - 3 months ago 18
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!

Answer

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>

<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>
</style>

If you have problems with the suggestionRowLayout attribute you can try the solution http://stackoverflow.com/a/26581489/1374015. Alternatively, you could try to use the old searchView* theme attributes as you can see in this post.

Comments