I’m trying to change search suggestions to “light theme”. I’m using appcompat-v7:22.2.0 library and read about new feature for customizing search view widget (android.support.v7.widget.SearchView).
FIRST TRY SECTION
Toolbar
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
Main Theme
<style name="Main.Theme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/red</item>
<item name="colorPrimaryDark">@color/red_dark</item>
<item name="searchViewStyle">@style/Main.Theme.SearchView</item>
</style>
SearchView Theme
<style name="Main.Theme.SearchView" parent="Widget.AppCompat.Light.SearchView">
<item name="voiceIcon">@mipmap/test_icon</item>
</style>
This way I'm not able to affect the search view. To test it I'm changing the voice icon in the search view, and it doesn't change from default.
SECOND TRY SECTION
The second try was to override the overlay theme in toolbar:
Overlay Theme
<style name="Main.Theme.Overlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="searchViewStyle">@style/Main.Theme.SearchView</item>
</style>
This way I've some feedback, but I lose "material design", in particular I've the "old" hint icon and it's underlined. My final aim is to change the search suggestion row background:
Suggestion row layout
<item name="suggestionRowLayout">@layout/my_custom_layout</item>
I think that I'm far away to accomplish this...can you help me?
Suggestions is a dynamic list created by system and is not an activity. So you cannot apply light theme to it.
Instead you can customize suggestions to give it feel like a light theme by using style.
use this
hint_row.xml
And apply this style
Now I am getting this
You can give more style according to your need