An SO User
An SO User

Reputation: 25028

How to theme SearchView suggestions?

I am trying to theme the dialog which shows the "recent search" in the SearchView. I did go over this answer Toolbar Search Suggestions Theming however, is there any way to theme the suggestions without having to manually load the suggestions?

Currently, the suggestions have a black background with white text.

How do I change this to a white background with grey-ish text?

Upvotes: 1

Views: 769

Answers (1)

Nauman Zubair
Nauman Zubair

Reputation: 1206

Below is quick and easy way to change the background and text color of recent search provided by SearchRecentSuggestionsProvider

<style name="AppTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- customize the color palette -->
    <item name="colorPrimary">@color/color_primary</item>
    <item name="colorPrimaryDark">@color/color_primary_dark</item>
    <item name="colorAccent">@color/color_accent</item>

    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>

    <item name="autoCompleteTextViewStyle">@style/myAutoCompleteTextViewStyle</item>
    <item name="textAppearanceSearchResultTitle">@style/mySearchResult</item>

</style>

<style name="myAutoCompleteTextViewStyle" parent="Widget.AppCompat.Light.AutoCompleteTextView">
    <item name="android:popupBackground">#ffffff</item>
</style>

<style name="mySearchResult" parent="TextAppearance.AppCompat.SearchResult.Title">
    <item name="android:textColor">#000000</item>
</style>

enter image description here

Upvotes: 2

Related Questions