Forum Xamarin Xamarin.Forms

NavigationPage Icons

arturmullerarturmuller Member ✭✭✭
edited January 27 in Xamarin.Forms

I am trying to specify Icons for my bottom toolbar, I have the following code:

On Platform="Android" Value="@drawable/calendar-check"/

I download the icons from material design icons and got a package with the different sizes. I extracted them to respective folders in /Resources. So now I have a bunch of files in these folders, e.g. ic_calendar_check_grey600_18dp.png. How do I then address it in my code above? I have tried several different ways, such as

On Platform="Android" Value="@drawable/ic_calendar_check"/
On Platform="Android" Value="ic_calendar_check_grey600"/

And several other alternatives but I cant find what is the correct way to import the image/icon. Any tips? Currently Im focusing on Android. I am also not sure what "dp" version of the image to choose.

Best Answer


  • LeoZhuLeoZhu Member ✭✭✭
    edited January 28

    you could put your images into the different drawable folders with the same name,like drawable-hdpi,drawable-xxhdpi ,drawable-xxhdpi ,drawable-xxxhdpi,it will select the image from the different drawable folder base on the android device resolutions

  • arturmullerarturmuller Member ✭✭✭

    But what would the filename of the image be? I have in these folders several images, such as calendar_check_black_18dp.png

    If I write
    On Platform="Android" Value="@drawable/calendar_check_black"/

    It still does not display it

  • JoeMankeJoeManke USMember ✭✭✭✭✭

    The files should all have the exact same name (calendar_check_black.png) and be placed in the appropriate folder for the size (drawable-hdpi, drawable-xhdpi, etc.).

    Then in Forms, you reference either "calendar_check_black" or "calendar_check_black.png".

  • arturmullerarturmuller Member ✭✭✭
    edited January 29

    Is this possible on Android? I have placed all images the folders as you mentioned, and this is my code:

    still no icons are displayed. This is located in the TabbedPage.Children tag

  • JoeMankeJoeManke USMember ✭✭✭✭✭
    edited January 30

    Show us the structure of the Resources folder in your Android project.

    Side note, Page.Icon is obsolete, you should use Page.IconImageSource instead.

  • arturmullerarturmuller Member ✭✭✭

    Hi @JoeManke , thanks for the reply!

    This is my Resources folder, each of these folders (mipmap-hdpi, mipmap-mdpi etc) has an image file called "calendar_check_black.png". I took the icon with the highest "DP" value.

  • JoeMankeJoeManke USMember ✭✭✭✭✭
    edited January 30

    The mipmap directories are only for the app icon which is shown on the home screen. You should create drawable-hdpi, etc. and place the images there.

  • arturmullerarturmuller Member ✭✭✭

    I created these folders and put the images there but still the icon does not show.

  • arturmullerarturmuller Member ✭✭✭

    That was the problem, thank you @JoeManke !

Sign In or Register to comment.