Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change color of android.support.v7.widget.SearchView

I am using search view.

  <android.support.v7.widget.SearchView
            android:id="@+id/searchView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_toLeftOf="@+id/imageViewMenu"
            >
  </android.support.v7.widget.SearchView>

Is this possible to change text color and icon color to view?

Currently it shows black text and icon. I want to change it to white color text and white search icon.

like image 693
Learning Always Avatar asked Jul 29 '16 11:07

Learning Always


1 Answers

This may work..

SearchView searchView = (SearchView) findViewById(R.id.search);
EditText searchEditText = (EditText)searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
searchEditText.setTextColor(getResources().getColor(R.color.white));
searchEditText.setHintTextColor(getResources().getColor(R.color.white));
like image 71
KrishnaJ Avatar answered Sep 28 '22 11:09

KrishnaJ