naiyu
naiyu

Reputation: 775

How to change the Clear Icon in SearchView of Actionbar

I used the appcompat to implemented the actionbar, now I want to change the clear icon. And I have done this:

<item android:id="@+id/action_search_note"
      android:title="@string/search_title"
      android:orderInCategory="101"
      android:icon="@drawable/ic_action_search"
      snailnote:showAsAction="collapseActionView|ifRoom"
      snailnote:actionViewClass="android.support.v7.widget.SearchView" />

my team:

<item name="searchViewCloseIcon">@drawable/search_clear_normal</item>

I also tried to add

<item name="android:searchViewCloseIcon">@drawable/search_clear_normal</item>

but it is giving an error, and I final removed it.

But it dosen't work, how should I change the clear icon in a right way.

Upvotes: 1

Views: 1036

Answers (2)

<style name="SearchViewStyle" parent="Widget.AppCompat.SearchView">
    <item name="closeIcon">@drawable/search_clear_normal </item>
</style>

Upvotes: 0

zhixin yang
zhixin yang

Reputation: 11

<style name="AppTheme" parent="@style/Theme.Base.AppCompat.Light.DarkActionBar">
    <item name="actionBarWidgetTheme">@style/YourActionBarWidget</item>
</style>

<style name="YourActionBarWidget" parent="@style/Theme.AppCompat">
    <item name="searchViewCloseIcon">@drawable/xxx</item>
</style>

Upvotes: 1

Related Questions