Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the toolbar SearchView Underline color to GRAY

I am trying to change the underline color of search view when we expand the search bar`

    SearchView.SearchAutoComplete autoCompleteTextView = (SearchView.SearchAutoComplete) searchView.findViewById(R.id.search_src_text);
    autoCompleteTextView.setCursorVisible(true);
    autoCompleteTextView.setTextColor(ContextCompat.getColor(this, R.color.textcolor_light_gray));
    autoCompleteTextView.setHintTextColor(autoCompleteTextView.getTextColors().withAlpha(255));
    autoCompleteTextView.setTextSize(16);

    View searchplate = (View)searchView.findViewById(android.support.v7.appcompat.R.id.search_plate);
    searchplate.setBackgroundResource(R.drawable.autocomplete_bg);

Here i used the theme to change the color also

 <style name="MySearchViewStyle" parent="Widget.AppCompat.Light.SearchView">
    <!-- Background for the search query section (e.g. EditText) -->
    <item name="queryBackground">@color/darkgray</item>

</style>

but nothing working for me. any one help me pls...

like image 987
sree Avatar asked Dec 10 '22 14:12

sree


1 Answers

Finally i got the solution..

    View searchplate = (View)searchView.findViewById(android.support.v7.appcompat.R.id.search_plate);
    searchplate.getBackground().setColorFilter(Color.DKGRAY, PorterDuff.Mode.MULTIPLY);
like image 172
sree Avatar answered Mar 17 '23 07:03

sree