I would like to resize icons in my Xamarin.Forms application. What should i do?

I added many icons to the drawable-... folders with the dimentions:

  • 36x36 (0.75x) for low-density (ldpi)
  • 48x48 (1.0x baseline) for medium-density (mdpi)
  • 72x72 (1.5x) for high-density (hdpi)
  • 96x96 (2.0x) for extra-high-density (xhdpi)
  • 144x144 (3.0x) for extra-extra-high-density (xxhdpi)
  • 192x192 (4.0x) for extra-extra-extra-high-density (xxxhdpi)

However icons are definitely too big.

Maybe its also important, i decided to create an renderer of searchbar to change icon.

protected override void OnElementChanged(ElementChangedEventArgs<SearchBar> args)
        {
            base.OnElementChanged(args);

            if (Control != null)
            {
                var searchView = Control;
                searchView.Iconified = true;
                searchView.SetIconifiedByDefault(false);
                // (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(Droid.Resource.Drawable.fa_search);
            }
        }

Thats the result: https://ibb.co/stknCG4. My icon should have dimentions as an arrow on the left.

0 Answers