How to remove bottom line in android SearchView component? Like in this image:
Asked
Active
Viewed 1.0k times
12

yozhik
- 4,644
- 14
- 65
- 98
-
1you can refer to this link. It might help https://stackoverflow.com/questions/30842921/how-to-remove-white-underline-in-a-searchview-widget-in-toolbar-android – HarshitMadhav Jun 21 '18 at 16:03
-
Thanks, helped me for 100% – yozhik Jun 21 '18 at 16:15
-
3Possible duplicate of [How to remove white underline in a SearchView widget in Toolbar Android](https://stackoverflow.com/questions/30842921/how-to-remove-white-underline-in-a-searchview-widget-in-toolbar-android) – HarshitMadhav Jun 21 '18 at 16:24
-
I am glad I was able to help you :-) cheers! – HarshitMadhav Jun 21 '18 at 16:26
7 Answers
27
<androidx.appcompat.widget.SearchView
app:queryBackground="@null"
...
/>
Setting this to @null in your XML will remove the colored bar.

Peterdk
- 15,625
- 20
- 101
- 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,639
- 3
- 64
- 69
-
1If I want to have custom background and also don't want that underline, your answer won't work... – Siddharth Thakkar Nov 07 '20 at 12:52
4
If you using the android namespace in your SearchView
xml, the best way to remove the bottom line is:
android:queryBackground="@null"

Phil Culver
- 75
- 2
- 8
2
In layout.xml
<SearchView
android:theme="@style/AppSearchView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="8dp"
android:background="@drawable/round_corner_rect"
android:queryBackground="@null"
android:queryHint="Search here..."
android:iconifiedByDefault="false" />
style.xml
<style name="AppSearchView" parent="Widget.AppCompat.SearchView">
<item name="android:editTextColor">@color/text_color</item>
<item name="android:textColor">@color/text_color</item>
<item name="android:textColorHint">@color/text_color</item>
<item name="android:textSize">12sp</item>
<item name="android:fontFamily">@font/app_font</item>
</style>

ramji
- 1,982
- 2
- 13
- 13
0
Use: app:queryBackground="@color/your_color"
and android:background="@color/your_color"

O Thạnh Ldt
- 1,103
- 10
- 11
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
- 274
- 1
- 9