Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android how to style a SearchView in Actionbar?

I need to change the style of my SearchView in my ActionBar. In particular I need to change the text hint color and the SearchView icons if possible. How can I accomplish this in XML (is it even possible in XML)?

If this isn't possible, how can I easily recreate similar behavior with a custom view? The close/expand behavior of the SearchView is particularly useful for me.

like image 986
galaxy infinite Avatar asked Feb 08 '12 18:02

galaxy infinite


1 Answers

Have you tried something like this (With ActionBarSherlock):

AutoCompleteTextView searchText = (AutoCompleteTextView) searchView.findViewById(R.id.abs__search_src_text);
searchText.setHintTextColor(getResources().getColor(R.color.white));
searchText.setTextColor(getResources().getColor(R.color.white));

It works fine for me.

like image 150
Tobias Reich Avatar answered Nov 15 '22 09:11

Tobias Reich