I want to change the text color of search view hint, but I tried in many ways with no success. Like in this post: Changing action bar searchview hint text color
I'm using Appcompat, support library of actionbar.
I tried this with null pointer return:
AutoCompleteTextView searchText = (AutoCompleteTextView) searchView.findViewById(R.id.abs__search_src_text);
searchView.findViewById(R.id.abs__search_src_text);
searchText.setHintTextColor(getResources().getColor(R.color.white));
searchText.setTextColor(getResources().getColor(R.color.white));
I found the answer here too:
Wrong id for the AutoCompleteTextView, I guess. Unless you use a custom Action Bar Search widget. Try smth. like the following:
Using the following code:
getResources().getColor(R.color.white)
it is possible that an alert saying that
getColor(int) is deprecated
appears. This is because from api 23, a newgetColor()
method was added to the ContextCompat.So just use the following:
It worked for me.