There are times when you’ll want to change the hint (placeholder) color and the text color of a SearchView widget. Here’s a small snippet that’ll allow us to do it:

Java
int searchSrcTextId = getResources().getIdentifier("android:id/search_src_text", null, null);

EditText searchEditText = (EditText) searchView.findViewById(searchSrcTextId);

searchEditText.setTextColor(Color.BLUE); // set the text color

searchEditText.setHintTextColor(Color.BLUE); // set the hint color

Based on the placement of the SearchView, the code to get the View object will differ. If it’s in the action bar (menu) then this is what we’ll be doing in the onCreateOptionsMenu method of the Activity or Fragment:

Java
SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();

If it is in the Activity’s (or Fragment’s) content layout then just use the findViewById() method to get the view with the given ID.