yozhik
yozhik

Reputation: 5074

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

Upvotes: 14

Views: 11795

Answers (7)

ramji
ramji

Reputation: 1992

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>

Upvotes: 2

Vahit Keskin
Vahit Keskin

Reputation: 438

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

Upvotes: 0

Phil Culver
Phil Culver

Reputation: 95

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

android:queryBackground="@null"

Upvotes: 6

Peterdk
Peterdk

Reputation: 16005

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

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

Upvotes: 32

harshita
harshita

Reputation: 497

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

Upvotes: 0

O Thạnh Ldt
O Thạnh Ldt

Reputation: 1223

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

Upvotes: 0

Michael
Michael

Reputation: 9834

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

Upvotes: 6

Related Questions