How to remove bottom line in android SearchView component?
Asked Answered
R

7

14

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

enter image description here

Rustproof answered 21/6, 2018 at 15:57 Comment(4)
you can refer to this link. It might help #30843421Adorable
Thanks, helped me for 100%Rustproof
Possible duplicate of How to remove white underline in a SearchView widget in Toolbar AndroidAdorable
I am glad I was able to help you :-) cheers!Adorable
M
6

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
Mallen answered 25/10, 2018 at 20:16 Comment(1)
If I want to have custom background and also don't want that underline, your answer won't work...Pledge
C
31
<androidx.appcompat.widget.SearchView
  app:queryBackground="@null"
  ...
/>

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

Clarisclarisa answered 13/1, 2020 at 17:0 Comment(0)
M
6

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
Mallen answered 25/10, 2018 at 20:16 Comment(1)
If I want to have custom background and also don't want that underline, your answer won't work...Pledge
S
5

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

android:queryBackground="@null"

Skimpy answered 19/8, 2020 at 19:32 Comment(0)
H
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>
Haemolysin answered 8/10, 2022 at 13:38 Comment(0)
D
0

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

Dannie answered 17/1, 2019 at 4:5 Comment(0)
R
0

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

Review answered 17/1, 2019 at 4:41 Comment(0)
W
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

Weakkneed answered 14/4, 2022 at 7:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.