SearchView 修改字体颜色和Hint颜色


代码修改

SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
if(searchView == null) {
   return;
}  
int id = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
TextView textView = (TextView) searchView.findViewById(id);
textView.setTextColor(Color.BLACK);  textView.setHintTextColor(Color.parseColor("#CCCCCC"));

或者直接在Styles中修改   Actionbar主题  android:actionBarWidgeTheme

    <style name="PeopleTheme" parent="@android:style/Theme.Holo.Light.DarkActionBar">
        <item name="android:actionBarStyle">@style/ContactsActionBarStyle</item>
        <item name="android:actionBarItemBackground">@drawable/action_bar_item_background</item>
       <strong> <item name="<strong>android:actionBarWidgetTheme</strong>">@style/ContactsActionBarTheme</item></strong>




    <style name="ContactsActionBarTheme" parent="@android:style/Theme.Holo">
    <strong>    <item name="android:textColorHint">#CCCCCC</item>
        <item name="android:textColor">@android:color/black</item></strong></strong>
        <item name="android:popupMenuStyle">@android:style/Widget.Holo.Light.PopupMenu</item>
        <item name="android:dropDownListViewStyle">@style/ListViewDropdownStyle</item>
    </style>


你可能感兴趣的:(SearchView 修改字体颜色和Hint颜色)