1

I'm using AppBarLayout search widget in my app. Everything works fine but I'm completely stuck up with removing the underline below search field in my AppBarLayout.

The following was nonsense code. It did not resolve...

findViewById<View>(R.id.search_plate).setBackgroundColor(ContextCompat.getColor(context, android.R.color.white))
CBnotes
  • 11
  • 1

3 Answers3

0

try this

val v = searchView.findViewById(android.support.v7.appcompat.R.id.search_plate);
v.setBackgroundColor(Color.parseColor("Colour code"));

hope this will help you

Nandu
  • 63
  • 11
  • have you tried these [link](https://stackoverflow.com/questions/30842921/how-to-remove-white-underline-in-a-searchview-widget-in-toolbar-android) – Nandu Apr 24 '20 at 16:37
0

My answer is late but i hope it helps anyone use the next line to find the search_plate

findViewById<View>(androidx.appcompat.R.id.search_plate)

but make sure that you are using androidx.appcompat.widget.SearchView in your xml and your activity otherwise you will get Null Exception

0

try this in searchview in xml

API below 21

android:queryBackground="@android:color/transparent"

API 21 and above

app:queryBackground="@android:color/transparent"