Search code examples
androidandroid-tvleanback

Change SearchView default icon for BrowseFragment for Android TV applications?


For Leanback BrowseFragment, by default there is a search view to the left of the screen. Is it a way to change the default icon of that SearchOrbView or hide it.

https://cdn-images-1.medium.com/max/800/1*oIFbcdjYrIqxU55-B23tjA.gif


Solution

  • if you want to change the icon then in you styles.xml

     <style name="NewSeachTheme" parent="Theme.Leanback">
        <item name="searchOrbViewStyle">@style/CustomSearchOrbView</item>
        <item name="defaultSearchColor">@color/transparent</item>
    </style>
    
    <style name="CustomSearchOrbView" parent="Widget.Leanback.SearchOrbViewStyle">
        <item name="searchOrbIcon">add your drawable here</item>
        <item name="searchOrbIconColor">@color/transparent</item>
    </style>
    

    Here the searchOrbIconColor is transparent because if your icon is small then the default icon color will be shown behind the search icon you use. Then add the new style "NewSeachTheme" to the Theme in manifest. Happy coding :)