question

Oregon39-5606 avatar image
0 Votes"
Oregon39-5606 asked ·

Toolbar image icons not displaying (Android)

I have the images in the Android project Resources folder. I also tried the assets folder, but that didn't work either. I've tried changing the Build Action setting (AndroidResource, Content, EmbeddedResource etc.) as well as removing the extension of the image in the Xaml. Unfortunately, none of these solution have worked. Other images are working correctly. It seems to be a problem with the toolbar. I've seen some others have this same issue in other forums.

How can I get the image icon, instead of the default text, to show up in the toolbar on Xamarin Forms Android?

dotnet-xamarinforms
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JarvanZhang-MSFT avatar image
1 Vote"
JarvanZhang-MSFT answered ·

Hello,​

Welcome to our Microsoft Q&A platform!

Hi, @Oregon39-5606 . How did you display the icon on toolbar? I created a basic demo to test the function, it works fine on Android. The image file is placed under Resources\drawable and the BuildAction is the default AndroidResource.

<ContentPage ...
    <ContentPage.ToolbarItems>
        <ToolbarItem IconImageSource="grid_"/>
    </ContentPage.ToolbarItems>
    ...
</ContentPage>

Best Regards,

Jarvan Zhang



If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 2 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


Hi @JarvanZhang-MSFT , Thanks for your response.

I had the images in the root of my Resources folder as well as in my Resources\drawable folder. However, I only changed the Build Actions on the images in my Resources folder but the Actions in the Resource\drawable folder were set to Content. Changing those build actions to AndroidResource solved the problem. Thanks for confirming the images should go in the Resources\drawable folder and that the Build Action should be AndroidResource.

0 Votes 0 ·

You're welcome. Happy coding!

1 Vote 1 ·