0

I'm adding a SearchView within a Toolbar of the app. When activated, the search input text's background is semi-transparent white. How to make it be fully transparent? enter image description here

khusrav
  • 5,267
  • 5
  • 27
  • 38
  • In case helps anyone - found the answer [here](https://stackoverflow.com/questions/28017396/how-can-i-style-the-searchview-when-using-a-toolbar-as-an-action-bar/28018439#28018439), how could I miss it? – khusrav Jun 07 '16 at 07:01

2 Answers2

0

You can change the background color when you create your searchView like this:

SearchView searchView = findViewById(R.id.searchView); 
EditText editText = (EditText)searchView.findViewById(context.getResources().getIdentifier("android:id/search_src_text", null, null));
editText.setBackgroundColor(Color.TRANSPARENT);
TychoTheTaco
  • 664
  • 1
  • 7
  • 28
  • 1
    while this may work,I don't like the solution, it is very error-prone - I don't want to know the internals of the SearchView to modify it, this pure styling issue. – khusrav Jun 07 '16 at 06:18
0

so I know some time has passed, but I had similiar problem with different color for toolbar and searchview even if I set the same for both. What helped for me was instead of setting background color for SearchView setting the backgroundTint, so:

instead of android:background="#BF29D2EB" use android:backgroundTint="#BF29D2EB" for your SearchView

M. Wojcik
  • 2,301
  • 3
  • 23
  • 31