Reputation: 566
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.
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