Search code examples
androidsearchview

change color of left back button of searchview


I want to change the color of back button in searchView(not the one of actionBar), but after a lot of tryings(customise a searchView/replace icon) just could not find any solution.The arrow on the left of the search icon should be white but I cannot change it. Hope somebody could do me a favour on this, really urge!!!

enter image description here

Part of sourceCode:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item
    android:id="@+id/search_action_search"
    android:icon="@drawable/icon_search_selector"
    android:title="@string/search_title"
    app:actionViewClass="android.support.v7.widget.SearchView"
    app:showAsAction="always|collapseActionView" /></menu>


@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.menu_search, menu);
    final MenuItem searchItem = menu.findItem(R.id.search_action_search);
    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    if (searchItem != null) {
        SearchView searchView = (SearchView) searchItem.getActionView();

Solution

  • Check your styles.xml for the base application theme, usually named AppTheme and change the parent to another theme. I used to have the same problem as you, black SearchView icon and arrow. But I changed the parent from Theme.AppCompat.Light.DarkActionBar to Theme.AppCompat.NoActionBar because I have my own toolbar as an action bar, and the SearchView icon and arrow changed to white.