11

How to remove bottom line in android SearchView component? Like in this image:

enter image description here

yozhik
  • 4,034
  • 13
  • 58
  • 95

6 Answers6

22
<androidx.appcompat.widget.SearchView
  app:queryBackground="@null"
  ...
/>

Setting this to @null in your XML will remove the colored bar.

Peterdk
  • 15,137
  • 19
  • 99
  • 140
4

When you get a reference to your SearchView; This will work:

val backgroundView = searchView.findViewById(android.support.v7.appcompat.R.id.search_plate) as View
backgroundView.background = null
Michael
  • 9,172
  • 3
  • 61
  • 66
1

If you using the android namespace in your SearchView xml, the best way to remove the bottom line is:

android:queryBackground="@null"

Phil Culver
  • 45
  • 2
  • 8
0

Use: app:queryBackground="@color/your_color" and android:background="@color/your_color"

O Thạnh Ldt
  • 829
  • 9
  • 11
0

Try to set background="@null" in xml in search view.

harshita
  • 427
  • 1
  • 4
  • 17
0

Just write it in xml:

<androidx.appcompat.widget.SearchView
   android:id="@+id/searchView"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   app:queryBackground="@null"
   ... />

Worked for me

Vahit Keskin
  • 141
  • 5