title: How to remove white underline in a SearchView widget in Toolbar Android
body: <p>I am using the Toolbar search widget in my project. Everything works fine but expect the thing which I am completely stuck up with removing the underline below the search field in my toolbar. I have tried many solutions and nothing works out. Below are some of the solutions that I tried.</p>
  <p><strong>Requirement is to remove white underline in the image</strong></p>
  <p><img src="https://i.stack.imgur.com/DrEYH.png" alt="enter image description here" /></p>
  <p><strong>Ist Solution:</strong></p>
  <pre><code>//Removing underline
  
      int searchPlateId = searchView.getContext().getResources().getIdentifier(&quot;android:id/search_plate&quot;, null, null);
      View searchPlate = searchView.findViewById(searchPlateId);
      if (searchPlate!=null) {
          searchPlate.setBackgroundColor (Color.TRANSPARENT);
          int searchTextId = searchPlate.getContext ().getResources ().getIdentifier (&quot;android:id/search_src_text&quot;, null, null);
  
      }
  </code></pre>
  <p><strong>IInd Solution:</strong></p>
  <pre><code> EditText searchEdit = ((EditText)searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text));
   searchEdit.setBackgroundColor(Color.TRANSPARENT);
  </code></pre>
  <p>The above code works to change the background of EditText but still underline is displaying below the close icon in SearchBar.</p>
  <p><strong>Complete code that I am using for SearchBar widget as follows:</strong></p>
  <pre><code>    @Override
      public void onCreateOptionsMenu(Menu menu, MenuInflater infl) {
          super.onCreateOptionsMenu(menu, infl);
          MenuInflater inflater = getActivity().getMenuInflater();
          inflater.inflate(R.menu.action_search, menu);
          final SearchView searchView = (SearchView) MenuItemCompat
                  .getActionView(menu.findItem(R.id.search));
  
          SearchManager searchManager = (SearchManager) getActivity ().getSystemService (getActivity ().SEARCH_SERVICE);
          searchView.setSearchableInfo (searchManager.getSearchableInfo (getActivity ().getComponentName ()));
  
          //changing edittext color
          EditText searchEdit = ((EditText)searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text));
          searchEdit.setTextColor(Color.WHITE);
  }
  </code></pre>
  <p><strong>action_search.xml</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;menu xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:compat=&quot;http://schemas.android.com/apk/res-auto&quot;&gt;
      &lt;item android:id=&quot;@+id/search&quot;
          android:title=&quot;Search&quot;
          android:icon=&quot;@drawable/abc_ic_search_api_mtrl_alpha&quot;
          compat:showAsAction=&quot;ifRoom|collapseActionView&quot;
          compat:actionViewClass=&quot;android.support.v7.widget.SearchView&quot; /&gt;
  &lt;/menu&gt;
  </code></pre>
  <p>possible duplicate of <a href="https://stackoverflow.com/questions/11085308/changing-the-background-drawable-of-the-searchview-widget/11669808#11669808">this</a></p>