Styling android search view and drop down list in actionbar

Kurian Vithayathil picture Kurian Vithayathil · Jan 6, 2015 · Viewed 14.4k times · Source

In my app, I have a searchview that displays search suggestions. I want the dropdown/spinner and text to be a particular color. Currently the only change I've been able to make is the text color of the inputted text via the following:

   <style name="MyApp.AutoCompleteTextView" parent="Widget.AppCompat.Light.AutoCompleteTextView">
    <item name="android:textColor">@color/white</item>
    <item name="android:textCursorDrawable">@null</item>
    <item name="android:background">@color/myBackgroundColor</item>
  </style>

The app currently displays the searchview results like this:

Here is how it currently looks

What I would like to know is how would I go about changing parts like the searchHint color, the drop down background and the drop down item text color?

I am targeting API 19+

Answer

huangming picture huangming · Apr 26, 2015

In your styles.xml, set the following to your AppTheme

<style name="AppTheme" parent="AppTheme.Base">
    <!-- Customize your theme here. -->
    <item name="android:dropDownItemStyle">@style/myDropDownItemStyle</item>
</style>

<style name="myDropDownItemStyle" parent="Widget.AppCompat.DropDownItem.Spinner">
    <item name="android:textColor">@color/secondary_text_default_material_light</item>
</style>

This can change the drop down item text color. Have a try.