diff --git a/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellSearchView.cs b/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellSearchView.cs index f3041b568168..6bd4d96049eb 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellSearchView.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellSearchView.cs @@ -11,8 +11,8 @@ using Android.Widget; using AndroidX.AppCompat.Widget; using AndroidX.CardView.Widget; +using AndroidX.Core.Content; using Java.Lang; -using Microsoft.Maui.Controls.Platform.Compatibility; using AColor = Android.Graphics.Color; using AImageButton = Android.Widget.ImageButton; using ASupportDrawable = AndroidX.AppCompat.Graphics.Drawable; @@ -317,12 +317,22 @@ AImageButton CreateImageButton(Context context, BindableObject bindable, Bindabl result.SetScaleType(ImageView.ScaleType.FitCenter); if (bindable.GetValue(property) is ImageSource image) + { AutomationPropertiesProvider.SetContentDescription(result, image, null, null); - ((ImageSource)bindable.GetValue(property)).LoadImage(MauiContext, (r) => + image.LoadImage(MauiContext, (r) => + { + result.SetImageDrawable(r?.Value); + }); + } + else if (defaultImage > 0 && ContextCompat.GetDrawable(Context, defaultImage) is Drawable defaultDrawable) { - result.SetImageDrawable(r?.Value); - }); + result.SetImageDrawable(defaultDrawable); + } + else + { + result.SetImageDrawable(null); + } var lp = new LinearLayout.LayoutParams((int)Context.ToPixels(22), LP.MatchParent) { diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/SearchHandlerRendersCustomSearchIconAndClearIcon.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/SearchHandlerRendersCustomSearchIconAndClearIcon.png new file mode 100644 index 000000000000..6f5af206adea Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/SearchHandlerRendersCustomSearchIconAndClearIcon.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/SearchHandlerRendersDefaultSearchIconAndClearIcon.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/SearchHandlerRendersDefaultSearchIconAndClearIcon.png new file mode 100644 index 000000000000..910b1bad8744 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/SearchHandlerRendersDefaultSearchIconAndClearIcon.png differ diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue25067.xaml b/src/Controls/tests/TestCases.HostApp/Issues/Issue25067.xaml new file mode 100644 index 000000000000..4ceaa77e3354 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue25067.xaml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + +