首页 > 解决方案 > 如何在 AppBarLayout Android 中的 SearchView 的查询文本中删除下划线

问题描述

我在我的应用程序中使用 AppBarLayout 搜索小部件。一切正常,但我完全坚持在我的 AppBarLayout 中删除搜索字段下方的下划线。

以下是胡说八道的代码。它没有解决...

findViewById<View>(R.id.search_plate).setBackgroundColor(ContextCompat.getColor(context, android.R.color.white))

标签: androidkotlinsearchviewandroid-appbarlayout

解决方案


我的回答迟了,但我希望它可以帮助任何人使用下一行找到 search_plate

findViewById<View>(androidx.appcompat.R.id.search_plate)

但请确保您在 xml 和活动中使用androidx.appcompat.widget.SearchView否则您将获得 Null Exception


推荐阅读