如何删除android SearchView组件中的底线?

yoz*_*hik 7 android searchview android-toolbar

如何删除android SearchView组件中的底线?就像这张图片:

在此处输入图片说明

Pet*_*rdk 17

<androidx.appcompat.widget.SearchView
  app:queryBackground="@null"
  ...
/>
Run Code Online (Sandbox Code Playgroud)

在您的 XML 中将此设置为 @null 将删除彩色条。


Mic*_*ael 5

当你得到对你的的引用时SearchView;这将起作用:

val backgroundView = searchView.findViewById(android.support.v7.appcompat.R.id.search_plate) as View
backgroundView.background = null
Run Code Online (Sandbox Code Playgroud)


小智 5

如果您在 xml 中使用 android 命名空间SearchView,则删除底线的最佳方法是:

android:queryBackground="@null"