Android SearchView customisation

user5807086 picture user5807086 · Feb 28, 2017 · Viewed 25.6k times · Source

im new to android and i got stucked on something that i think it's simple but i got confused.. I need to make a custom searchView not in the actionbar/toolbar but in my Relativelayout. The problem is that i don't know hot to customise the background , textinput color , the search icon color in XML , or just the attributes of them . At the moment im on my phone and can't show my code . Does anyone tell me how i can customise it ? Maybe showing me any tutorial i can follow ? Thanks in advance !!!!

Answer

AGM Tazim picture AGM Tazim · Feb 28, 2017

Add this code on your 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>

Dont forget to change these icons.

And follow this SearchView to know each option of SearchView .