Setting Theme for SearchView

suggest change

Basically, to apply a theme for a SearchView extracted as app:actionViewClass from menu.xml, we need to understand that it depends completely on the style applied to the underlying Toolbar. To theme the Toolbar, apply the following steps. The Toolbar snippet uses app: and tools: and does not declare those namespaces.

Create a style in the styles.xml

<style name="ActionBarThemeOverlay">
     <item name="android:textColorPrimary">@color/prim_color</item>
     <item name="colorControlNormal">@color/normal_color</item>
     <item name="colorControlHighlight">@color/high_color</item>
     <item name="android:textColorHint">@color/hint_color</item>
</style>

Apply the style to the Toolbar.

<android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        app:theme="@style/ActionBarThemeOverlay"
        app:popupTheme="@style/ActionBarThemeOverlay"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/colorPrimary"
        android:title="@string/title"
        tools:targetApi="m" />

This gives the desired color to all the views corresponding to the Toolbar (back button, menu icons, and SearchView).

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents