@@ -133,14 +133,20 @@ public static void UpdateCancelButtonColor(this SearchView searchView, ISearchBa
133133 var cancelButton = searchView . GetCancelButton ( ) ;
134134 if ( cancelButton ? . Drawable is Drawable drawable )
135135 {
136- var image = searchView . FindViewById < ImageView > ( searchCloseButtonIdentifier ) ;
137-
138- if ( image is not null && image . Drawable is Drawable drawable )
136+ if ( cancelButton . Enabled )
139137 {
140138 if ( searchBar . CancelButtonColor is not null )
139+ {
141140 drawable . SetColorFilter ( searchBar . CancelButtonColor , FilterMode . SrcIn ) ;
141+ }
142142 else if ( TryGetDefaultStateColor ( searchView , AAttribute . TextColorPrimary , out var color ) )
143+ {
143144 drawable . SetColorFilter ( color , FilterMode . SrcIn ) ;
145+ }
146+ }
147+ else
148+ {
149+ drawable . ClearColorFilter ( ) ;
144150 }
145151 }
146152 }
@@ -166,21 +172,20 @@ internal static void UpdateSearchIconColor(this SearchView searchView, ISearchBa
166172 }
167173 }
168174
169- static readonly int closeButtonId = Resource . Id . search_close_btn ;
170-
171175 static ImageView ? GetCancelButton ( this SearchView searchView )
172176 {
173177 if ( searchView . Resources is null )
174178 {
175179 return null ;
176180 }
177181
182+ var closeButtonId = Resource . Id . search_close_btn ;
178183 if ( closeButtonId <= 0 )
179184 {
180185 return null ;
181186 }
182187
183- return searchView . FindViewById ( closeButtonId ) as ImageView ;
188+ return searchView . FindViewById < ImageView > ( closeButtonId ) ;
184189 }
185190
186191 public static void UpdateIsTextPredictionEnabled ( this SearchView searchView , ISearchBar searchBar , EditText ? editText = null )
0 commit comments