Text color of SearchView in ActionBar with ActionBarSherlock

前端 未结 2 1206
面向向阳花
面向向阳花 2021-01-14 01:17

I want to change the color of a text in an ActionBarSherlock SearchView, so I found this on StackOverflow:

AutoCompleteTextView searchText = (Au         


        
相关标签:
2条回答
  • 2021-01-14 02:05

    Change and apply your styles as follows:

    1. Overwrite SearchViewStyle that defines relevant style.

      <style name="SearchViewStyle" 
             parent="Widget.Sherlock.Light.SearchAutoCompleteTextView">
          <item name="android:textColor">myTextColor</item>
      </style>
      
    2. Add this style definition to your app theme.

      <style name="CustomTheme" parent="Theme.Sherlock.Light">
          ...
          <item name="searchAutoCompleteTextView">@style/SearchViewStyle</item>
          ...
      </style>
      
    3. Apply this theme in your Manifest (android:theme="CustomTheme").

    Hope this helps ... Cheers!

    p.s. search for SearchViewStyle in ABS style definitions (XML files). This way you can follow up available styles using Ctrl+click on definitions.

    0 讨论(0)
  • 2021-01-14 02:08

    other way, work for me

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
            searchView = new SearchView(getSupportActionBar().getThemedContext());
    
            AutoCompleteTextView searchText = (AutoCompleteTextView) searchView.findViewById(R.id.abs__search_src_text);
            searchText.setTextColor(Color.BLACK); 
    .....................
    }
    
    0 讨论(0)
提交回复
热议问题