Reputation: 1794
I am creating an Android application in Xamarin Forms. I am trying to add a ToolbarItem
icon using some of the examples from this forum using XAML like so:
<ToolbarItem Name="Add" Activated="OnAddClick"
Priority="1" Order="Primary" Icon="Create.png" />
My Create.png
icon file is located in /Resources/drawable/
located in the Android project. I have done the same thing in Android Studio using a menu layout file and my icons are visible. I am, however, struggling to accomplish the same result in Xamarin Forms. Is this a problem with Xamarin Forms or am I doing something wrong. Any suggestions?
Upvotes: 4
Views: 1606
Reputation: 34128
In order for this to work truly cross-platform, make sure the filename is compliant with all of the requirements for each platform. Specifically Android is known to be picky. Just only lowercase filenames without any special characters. You can only use lower-case letters, numbers, underscores and periods.
Example valid filename is create.png
or icon_create.png
.
Non-valid examples are: Create.png
, icon create.png
, create-icon.png
, etc.
Read more on the Xamarin documentation page.
As pointed out in the comments, Xamarin Studio does an excellent job of pointing out the illegal filenames.
Upvotes: 3