Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

How to edit icon of SearchBar Xamarin Forms on Android ?

RoexRoex FRMember ✭✭

Hello everyone ! I need your help !
I want to make a page with a SearchBar, but, my problem is the personalisation of the SearchBar icon, especially on the Platform Android. My search led me to nothing.
I would be very grateful if you know of a way to edit icon. (I have a model to follow, so It’s well the icon that I want to change and not the color).
Thank you in advance !


  • AmishiAmishi INMember

    Were you able to achieve this? I need to do a similar change.

  • jordydieltjensjordydieltjens USMember
    edited April 2017

    you need a renderer to achieve this :
    this is my code, it changes the search and the cancel icon
    `[assembly: ExportRenderer(typeof(CustomSearchBar), typeof(CustomSearchbarRenderer))]

    namespace namespace.Droid.Renderer
    public class CustomSearchbarRenderer : SearchBarRenderer
    protected override void OnElementChanged(ElementChangedEventArgs e)
    if (Control != null)
    var searchView = Control;
    searchView.Iconified = true;
    // (Resource.Id.search_mag_icon); is wrong / Xammie bug
    int searchIconId = Context.Resources.GetIdentifier("android:id/search_mag_icon", null, null);
    var icon = searchView.FindViewById(searchIconId);

                (icon as ImageView).SetImageResource(Resource.Drawable.youriconforsearch);
                int cancelIconId = Context.Resources.GetIdentifier("android:id/search_close_btn", null, null);
                var eicon = searchView.FindViewById(cancelIconId);
                (eicon as ImageView).SetImageResource(Resource.Drawable.youriconforcancel);


  • LeoJHarrisLeoJHarris NZMember ✭✭✭

    @jordydieltjens Dont forget to add the TElement

    protected override void OnElementChanged(ElementChangedEventArgs<SearchBar> e)

  • DimChrisDimChris USMember ✭✭✭✭

    Why dont you put a transparent button(with your png image inside) side by side your editext ?

Sign In or Register to comment.