Android SearchView 自定义

标签 android android-layout android-search

我是 android 的新手,我被困在一些我认为很简单但我很困惑的事情上.. 我需要在我的 Relativelayout 中而不是在操作栏/工具栏中创建自定义 searchView。问题是我不知道如何自定义背景、文本输入颜色、XML 中的搜索图标颜色,或者只是它们的属性。目前我正在使用手机,无法显示我的代码。有人告诉我如何自定义它吗?也许向我展示任何我可以遵循的教程?提前致谢!!!!

最佳答案

将此代码添加到您的 RelativeLayout -

<android.support.v7.widget.SearchView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@color/colorAsh"
        android:backgroundTint="@color/colorAsh"
        android:searchIcon="@drawable/ic_search"
        android:commitIcon="@drawable/ic_commit"
        android:searchHintIcon="@drawable/ic_search" 
        android:closeIcon="@drawable/ic_close" 
        android:goIcon="@drawable/ic_go">

    </android.support.v7.widget.SearchView>

不要忘记更改这些图标。

然后关注这个 SearchView了解 SearchView 的每个选项。

关于Android SearchView 自定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42515902/

相关文章:

android - 确定 Linux 缓存的内容

java - Android searchview 添加行到 ListView

Android:如何以编程方式使用新项目计数更新应用程序快捷方式图标

android - Xamarin 表单 : How to open an app from another app?

android - TextInputLayout float 标签自定义字体和edittext自定义字体

java - 无网络时如何更改 ADMOB 广告的背景颜色

android - 工具栏搜索建议主题

java - 在 Android 中设置搜索 View 时遇到问题

android - android studio 中 View 对象的 ClassCastException

android - 在 Android 中使用 Constraint-Layout helper Flow 进行布局定位