Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove bottom line in android SearchView component?

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

enter image description here

like image 603
yozhik Avatar asked Jun 21 '18 15:06

yozhik


People also ask

How do I use search view?

Android SearchView provides user interface to search query submitted over search provider. SearchView widget can be implemented over ToolBar/ActionBar or inside a layout. SearchView is by default collapsible and set to be iconified using setIconifiedByDefault(true) method of SearchView class.


3 Answers

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

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

like image 169
Peterdk Avatar answered Oct 20 '22 06:10

Peterdk


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

android:queryBackground="@null"

like image 40
Phil Culver Avatar answered Oct 20 '22 07:10

Phil Culver


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
like image 37
Michael Avatar answered Oct 20 '22 07:10

Michael