繁体   English   中英

更改android中SearchView项中搜索图标和文本的颜色

[英]Change the color of the search icon and text in SearchView item in android

我创建了一个自定义工具栏 (custom_ttolbar.xml),并将其添加到我的活动中。 我想将工具栏中的搜索图标更改为白色,将要输入的文本更改为白色,我该怎么做?

在此处输入图片说明

这是它的外观。

这是搜索视图的 xml 代码:

<SearchView
    android:layout_alignParentEnd="true"
    android:id="@+id/simpleSearchView"
    android:layout_height="30dp"
    style="@style/MySearchViewStyle"
    android:layout_width="wrap_content"/>

另外,单击搜索按钮时输入的文本是黑色的,我该如何更改?

对于搜索栏,您可以使用以下代码:

android:goIcon="@drawable/your_go_icon"
android:iconifiedByDefault="false"
android:queryHint="your_hint"
android:searchIcon="@drawable/your_search_icon"

您可以在android:searchIcon属性中使用您选择的任何图标(白色或其他颜色)。

对于文本颜色,我建议您遵循https://stackoverflow.com/a/40550067/8190327

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM