How can I change the action bar search view hint text colour?
This question explains how to get the EditText when using ABS: Android ActionBar Customize Search View
this worked for me :-)
EditText seartext = searchView.findViewById(R.id.search_src_text);
seartext.setTextColor(Color.WHITE);
seartext.setHintTextColor(Color.GRAY);
android:actionBarWidgetTheme of your main theme should point to a style that has a android:textColorHint in it. That one will allow changing the hint text color of the search view.
This is really simple to achieve using the styles.xml
Just understand that themeing the SearchView is directly related to the theme of the Toolbar from whose menu.xml
it is fetched as a app:actionViewClass
.
SearchView searchView= (SearchView) findViewById(R.id.searchView1);
int id = searchView.getContext()
.getResources()
.getIdentifier("android:id/search_src_text", null, null);
TextView textView = (TextView) searchView.findViewById(id);
textView.setTextColor(Color.WHITE);
this worked for me, hope it helps
((EditText) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text)).setHintTextColor(getResources().getColor(R.color.white));
also see this
Just get the textView
id of search widget and use setTextColor()
method to change the search text color and setHintTextColor()
to change the search hints text color.
// Get textview id of search widget
int id = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
TextView textView = (TextView) searchView.findViewById(id);
// Set search text color
textView.setTextColor(Color.WHITE);
// Set search hints color
textView.setHintTextColor(Color.GRAY);