locked
NavigationPage Icons RRS feed

  • Question

  • User392311 posted

    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. iccalendarcheckgrey60018dp.png. How do I then address it in my code above? I have tried several different ways, such as

    On Platform="Android" Value="@drawable/iccalendarcheck"/ On Platform="Android" Value="iccalendarcheck_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.

    Monday, January 27, 2020 10:52 PM

Answers

  • User53115 posted

    Is the build action on the images set to AndroidResource?

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, January 30, 2020 5:55 PM

All replies

  • User380718 posted

    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

    Tuesday, January 28, 2020 2:40 AM
  • User392311 posted

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

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

    It still does not display it

    Tuesday, January 28, 2020 9:53 AM
  • User53115 posted

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

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

    Tuesday, January 28, 2020 9:33 PM
  • User392311 posted

    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

    Wednesday, January 29, 2020 10:36 PM
  • User53115 posted

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

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

    Thursday, January 30, 2020 2:17 PM
  • User392311 posted

    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 "calendarcheckblack.png". I took the icon with the highest "DP" value.

    Thursday, January 30, 2020 5:15 PM
  • User53115 posted

    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.

    Thursday, January 30, 2020 5:18 PM
  • User392311 posted

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

    Thursday, January 30, 2020 5:32 PM
  • User53115 posted

    Is the build action on the images set to AndroidResource?

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, January 30, 2020 5:55 PM
  • User392311 posted

    That was the problem, thank you @JoeManke !

    Thursday, January 30, 2020 7:53 PM