Skip to content

Commit 44757c4

Browse files
committed
[android] Fallback to default icons in SearchHandler
If no QueryIcon / ClearIcon is specified use default icon.
1 parent 2fac3dc commit 44757c4

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellSearchView.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
using Android.Widget;
1212
using AndroidX.AppCompat.Widget;
1313
using AndroidX.CardView.Widget;
14+
using AndroidX.Core.Content;
1415
using Java.Lang;
15-
using Microsoft.Maui.Controls.Platform.Compatibility;
1616
using AColor = Android.Graphics.Color;
1717
using AImageButton = Android.Widget.ImageButton;
1818
using ASupportDrawable = AndroidX.AppCompat.Graphics.Drawable;
@@ -317,12 +317,22 @@ AImageButton CreateImageButton(Context context, BindableObject bindable, Bindabl
317317
result.SetScaleType(ImageView.ScaleType.FitCenter);
318318

319319
if (bindable.GetValue(property) is ImageSource image)
320+
{
320321
AutomationPropertiesProvider.SetContentDescription(result, image, null, null);
321322

322-
((ImageSource)bindable.GetValue(property)).LoadImage(MauiContext, (r) =>
323+
image.LoadImage(MauiContext, (r) =>
324+
{
325+
result.SetImageDrawable(r?.Value);
326+
});
327+
}
328+
else if (defaultImage > 0 && ContextCompat.GetDrawable(Context, defaultImage) is Drawable defaultDrawable)
323329
{
324-
result.SetImageDrawable(r?.Value);
325-
});
330+
result.SetImageDrawable(defaultDrawable);
331+
}
332+
else
333+
{
334+
result.SetImageDrawable(null);
335+
}
326336

327337
var lp = new LinearLayout.LayoutParams((int)Context.ToPixels(22), LP.MatchParent)
328338
{

0 commit comments

Comments
 (0)