I have my own theme for ActionBarSherlock based on Theme.Sherlock.Light.DarkActionBar
, here are my styles:
<style name="Theme.MyTheme" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="actionBarStyle">@style/Widget.MyTheme.ActionBar</item>
</style>
<style name="Widget.MyTheme.ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
<item name="android:background">@drawable/action_bar</item>
<item name="background">@drawable/action_bar</item>
</style>
Where @drawable/action_bar
is an xml:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle">
<solid android:color="@color/color_action_bar_bottom_line" />
</shape>
</item>
<item android:bottom="2dp">
<shape android:shape="rectangle">
<solid android:color="@color/color_action_bar_background" />
</shape>
</item>
</layer-list>
Everything looks great except one thing: the text in the SearchView (when I use the search mode in ActionBar) is "dark on dark", so I cannot see anything. I tried to set the text colors for SearchView manually:
AutoCompleteTextView searchTextView =
(AutoCompleteTextView) searchView.findViewById(R.id.abs__search_src_text);
searchTextView.setTextColor(Color.WHITE);
searchTextView.setHintTextColor(Color.LTGRAY);
searchTextView.setHighlightColor(Color.WHITE);
searchTextView.setLinkTextColor(Color.WHITE);
This helped a lot but I cannot change the color of autocomplete text:
As you see, it's still black. How can I set the white text color for this kind of text?
The issue is that the
SearchView
is initialized without properly considering theActionBar
style (in this case Dark ActionBar on Light) that is set. And the answer is to use theActionBar
themedContext
; retrieved byActivity.getActionBar().getThemedContext()
. This is mentioned at the bottom of ABS Migration:My code is how it is done in standard Android, you'd have to get the
ActionBar
however appropriate. If you pass the themedContext
to theSearchView
then it will use the appropriate style, namely, it won't render itself as if it were on a light background.Try this code
or
It's from my own answer here How to set SearchView TextSize?
Here iam useing SearchView like this it's working nice searchtext color also in white color.
this one
res/menu
and name isapplications_menu.xml
this one use in activity when you search like this
here is screen
I think your are using a Light Theme with a custom dark action bar theme. You could try to change the theme of the
AutoCompleteTextView
to a dark one. Try to add this in your theme :Edit : not sure about the added lines but you can try. I spot it in some fixes for the HoloEverywhere library.
May be there are is best way to do this , but used the very simple way, I used library for that
set the boolean value for true/false for setting Light/Dark theme
for changing the text color i changed the librery's layout/ holodark.xml
I solved this by disabling autocomplete feature (it will be disabled if you'll set the edit type to Visible Password), but this solution is not very good and I'm still in search for better one.