-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to change color of SearchBar magnifying glass icon #6094
Comments
Correct, this was inherited from Xamarin.Forms. We have an open PR here that makes the icon the same color as the text color. Would that make sense for you, or would you want to set it separately? |
I think it's fine for me but I'm sure that people would appreciate the freedom of setting the color independently from the text color but defaulting to be the same color. |
For anyone who might stumble to this issue. I've found a brute force way of setting the color on every Search Bar: Microsoft.Maui.Handlers.SearchBarHandler.Mapper.AppendToMapping("LightSearch", (h, v) =>
{
var children = h.PlatformView.GetChildrenOfType<ImageView>();
foreach(var child in children)
{
child.SetColorFilter(Colors.DarkGray.ToPlatform());
}
}); I tried doing it like they do in here: xamarin/Xamarin.Forms#14766 but that didn't work because the imageview wouldn't be found inside the PlatformView. So instead I just iterate through all the imageview inside the search bar and I set its color filter. |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
Any update on this? |
Hi, var plate = Control.FindViewById(Resources.GetIdentifier("android:id/search_plate", null, null));
plate.Background.SetColorFilter(new BlendModeColorFilter(Color.YellowGreen, BlendMode.Multiply)); With maui: var plate = handler.PlatformView.FindViewById(Platform.AppContext.Resources.GetIdentifier("android:id/search_plate", null, null));
plate.Background.SetColorFilter(new BlendModeColorFilter(col, BlendMode.Multiply));
Edit: I found a solution: var icon = handler.PlatformView.FindViewById<ImageView>(ResourceConstant.Id.search_mag_icon);
icon?.SetColorFilter(col);
var plate = handler.PlatformView.FindViewById(ResourceConstant.Id.search_plate);
plate?.Background?.SetColorFilter(new BlendModeColorFilter(col, BlendMode.Multiply)); |
Can anyone please confirm when is this fix planned for release? The magnifying glass icon color should (at least) match text color or (best) have its own bindable property; switching the app theme from light to dark or vice versa makes the magnifying glass become invisible which is not good at all. Also we should not be forced to use handlers for something like this. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@jfversluis Crazy that this is still an issue.. |
Description
The magnifying glass in SearchBar cannot be changed using Styles in XAML. This feels like a forgotten detail. The cancel button can be changed but not this which means that in Dark Mode you cannot see it.
Steps to Reproduce
Version with bug
Release Candidate 1 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
API 30, Android 11
Did you find any workaround?
I can change the background using a handler, but I cannot change the magnifying glass looks through a handler AFAIK.
Relevant log output
No response
The text was updated successfully, but these errors were encountered: