Skip to content

Instantly share code, notes, and snippets.

@bdiegel
Last active October 28, 2015 14:44
Show Gist options
  • Save bdiegel/60c7dcd4b6c7cd729c36 to your computer and use it in GitHub Desktop.
Save bdiegel/60c7dcd4b6c7cd729c36 to your computer and use it in GitHub Desktop.
Android SearchView Styling

SearchView styles

Two good resources philio.me novoda

v21 example:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="searchViewStyle">@style/AppTheme.SearchView</item>
</style>
<style name="AppTheme.SearchView" parent="Widget.AppCompat.SearchView">
    <item name="searchIcon">@drawable/ic_action_search</item>
    <item name="closeIcon">@drawable/ic_action_close</item>
</style>

code hack

mSearchView = (SearchView) searchViewMenuItem.getActionView();
int searchImgId = getResources().getIdentifier("android:id/search_button", null, null);
ImageView v = (ImageView) mSearchView.findViewById(searchImgId);
v.setImageResource(R.drawable.your_new_icon);  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment