Reputation: 343
I want it to be in black. I tried to change the textPrimaryColor but the search input field was also affected and I don't want that to happen.
Here's my styles for the Action Bar.
<style name="MyActionBar" parent="Theme.AppCompat.Light">
<item name="android:textColorPrimary">@android:color/white</item>
<item name="android:textColorPrimaryInverse">@android:color/white</item>
<item name="android:textColorHint">@android:color/white</item>
<item name="android:actionMenuTextColor">@android:color/white</item>
<item name="android:textColorSecondary">@android:color/white</item>
</style>
Upvotes: 7
Views: 2412
Reputation: 5371
I faced this issue before and created a work around for it.
/**
* @param viewGroup
* View to search for child views inside
* @param _class
* child view class inside the View
* @return child view of corresponding View class
*/
public static <V extends View> Collection<V> findChildrenByClass(ViewGroup viewGroup, Class<V> _class) {
return gatherChildrenByClass(viewGroup, _class, new ArrayList<V>());
}
/**
* @param viewGroup
* View to search for child views inside
* @param _class
* child view class inside the View
* @param childrenFound
* child view if found
* @return child view of corresponding View class
*/
@SuppressWarnings("unchecked")
private static <V extends View> Collection<V> gatherChildrenByClass(ViewGroup viewGroup, Class<V> _class, Collection<V> childrenFound) {
for (int i = 0; i < viewGroup.getChildCount(); i++)
{
final View child = viewGroup.getChildAt(i);
if (_class.isAssignableFrom(child.getClass())) {
childrenFound.add((V)child); // unchecked on this line
}
if (child instanceof ViewGroup) {
gatherChildrenByClass((ViewGroup) child, _class, childrenFound);
}
}
return childrenFound;
}
Here are two methods that find all child views of the SearchView
, currently, there are three childs for SearchView
:
TextView
which can be seen in the drop down suggestions listAutoCompleteTextView
which you type in inside the SearchView
ImageView
which is the close image to the right of the SearchView
Now, lets find the TextView
and then change its color. Do this in your Activity
or Fragment
:
// Setting up the TextView of searchView suggestions drop down list
for (TextView textView : findChildrenByClass(mSearchView, TextView.class)) {
textView.setHint("Type a word");
textView.setTextColor(Color.rgb(255, 255, 255));
textView.setHintTextColor(Color.argb(128, 255, 255, 255));
}
All done :)
Upvotes: 0
Reputation: 1000
I had the same problem and found the solution here: https://code.google.com/p/android/issues/detail?id=5237#c8
EDIT:
Try to override the style for the suggested text.
In your "MyActionBar" style add the following item:
<item name="android:autoCompleteTextViewStyle">@style/AutoCompleteTextViewLight</item>
And create the style AutoCompleteTextViewLight which fix the color:
<style name="AutoCompleteTextViewLight" parent="@android:style/Widget.AutoCompleteTextView">
<item name="android:textColor">@android:color/primary_text_light</item>
</style>
Upvotes: 4