warCommander
warCommander

Reputation: 449

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. 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 ?

enter image description here

Here how it look.

and here is the xml code for the search view:

<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 ?

Upvotes: 0

Views: 224

Answers (1)

Abdullah Z Khan
Abdullah Z Khan

Reputation: 1286

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.

For the text color, I suggest you follow https://stackoverflow.com/a/40550067/8190327

Upvotes: 1

Related Questions