SURYA S R
SURYA S R

Reputation: 566

SearchView expanded back button color

I have a fragment with Dark action bar (so white text and icon color)

im using the following menu item to create a searchview on click

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item
    android:id="@+id/action_search"
    android:icon="@drawable/ic_toolbar_search"
    android:title="@string/search"
    app:actionViewClass="androidx.appcompat.widget.SearchView"
    app:showAsAction="always|collapseActionView" />

</menu>

How to change the color of the back icon only when the searchView is expanded. By default the back icon color should have back icon with OnPrimary color.

Searchview's back icon also having OnPrimary color

Note : -> App's theme : Theme.MaterialComponents.DayNight.NoActionBar -> This is being done in a fragment & background color is being changed using the following method:

activity.supportActionBar?.setBackgroundDrawable(ColorDrawable(getColor(activity, R.color.surface)))

Upvotes: 0

Views: 17

Answers (0)

Related Questions