Android, how is SearchView style in the action bar?

I need to change the style of my SearchView in my ActionBar . In particular, I need to change the color of the text and SearchView icons, if possible. How can this be done in XML (is this possible in XML)?

If this is not possible, how can I easily recreate this behavior with a custom view? The close / expand SearchView behavior is especially useful to me.

+6
source share
4 answers

Have you tried something like this (using ActionBarSherlock):

 AutoCompleteTextView searchText = (AutoCompleteTextView) searchView.findViewById(R.id.abs__search_src_text); searchText.setHintTextColor(getResources().getColor(R.color.white)); searchText.setTextColor(getResources().getColor(R.color.white)); 

This works great for me.

+7
source

It looks like you might need to create your own layout for your search action. I could not find any documents that talk about changing SearchView by default. But this makes the close / expand behavior possible.

http://developer.android.com/guide/topics/ui/actionbar.html#ActionView

Related questions:

+1
source

You need to create a new theme and use it in the manifest file.

 <style name="Theme.Test" parent="@style/Theme.AppCompat.Light"> <item name="searchViewAutoCompleteTextView">@style/Theme.Test.SearchField</item> </style> <!-- Search edit text --> <style name="Theme.Test.SearchField" parent="@style/Widget.AppCompat.Light.AutoCompleteTextView"> <item name="android:textColor">@color/white</item> <item name="android:textColorHint">@color/white</item> </style> 

It worked for me.

0
source

The correct answer is to overload the style of the action bar widget using your own style. For a head light with a dark action bar, put this in your own stylesheet, for example res/values/styles_mytheme.xml :

 <style name="Theme.MyTheme" parent="@android:style/Theme.Holo.Light.DarkActionBar"> <item name="android:actionBarWidgetTheme">@style/Theme.MyTheme.Widget</item> <!-- your other custom styles --> </style> <style name="Theme.MyTheme.Widget" parent="@android:style/Theme.Holo"> <item name="android:textColorHint">@android:color/white</item> <!-- your other custom widget styles --> </style> 

Make sure your application uses the theme theme as described in the enter link here

0
source

Source: https://habr.com/ru/post/907972/


All Articles