Styling a SearchView in Android Action Bar

后端 未结 11 1629
小鲜肉
小鲜肉 2020-12-02 20:56

I have a search widget in my Action Bar like this:

\"Search

(1) How do I change

11条回答
  •  天涯浪人
    2020-12-02 20:57

    I have been spending many time for this but finally: :-)

    1. To change the text color :
    ((EditText)searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text)).setTextColor(Color.WHITE);
    

    or this one for AndroidX:

    ((EditText)searchView.findViewById(androidx.appcompat.R.id.search_src_text)).setTextColor(Color.WHITE);
    
    1. To change the text hint:
    ((EditText)searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text)).setHintTextColor(Color.WHITE);
    

    or this one for AndroidX:

    ((EditText)searchView.findViewById(androidx.appcompat.R.id.search_src_text)).setHintTextColor(Color.WHITE);
    

提交回复
热议问题