[英]Change the color of the search icon and text in SearchView item in android
I have created a custom toolbar (custom_ttolbar.xml) that I am adding it to my activity.我创建了一个自定义工具栏 (custom_ttolbar.xml),并将其添加到我的活动中。 I want to change the search icon in the toolbar to white and the text to be entered to be white how can I do that ?
我想将工具栏中的搜索图标更改为白色,将要输入的文本更改为白色,我该怎么做?
Here how it look.这是它的外观。
and here is the xml code for the search view:这是搜索视图的 xml 代码:
<SearchView
android:layout_alignParentEnd="true"
android:id="@+id/simpleSearchView"
android:layout_height="30dp"
style="@style/MySearchViewStyle"
android:layout_width="wrap_content"/>
Also, the text entered when I click the search button is black how do I change that also ?另外,单击搜索按钮时输入的文本是黑色的,我该如何更改?
for the search bar, you can use the following code:对于搜索栏,您可以使用以下代码:
android:goIcon="@drawable/your_go_icon"
android:iconifiedByDefault="false"
android:queryHint="your_hint"
android:searchIcon="@drawable/your_search_icon"
You can use any icon of your choice (white or otherwise) in the android:searchIcon
property.您可以在
android:searchIcon
属性中使用您选择的任何图标(白色或其他颜色)。
For the text color, I suggest you follow https://stackoverflow.com/a/40550067/8190327对于文本颜色,我建议您遵循https://stackoverflow.com/a/40550067/8190327
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.