SVG icons in android app

валера карманов 396 Reputation points
2024-10-04T11:59:18.1+00:00

Is it possible to use SVG icons in Android applications? Do I need to add any dependency to the project, something like this is written in the doc. Is it possible to describe in more detail how to work with them in XAML and C#?

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,596 questions
{count} votes

Accepted answer
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 32,386 Reputation points Microsoft Vendor
    2024-10-08T07:29:39.6633333+00:00

    Hello,

    Not only for the application icon, I want to use SVG in the entire application where the icon is used.

    .NET MAUI converts SVG files to PNG files. Therefore, when adding an SVG file to your .NET MAUI app project, it should be referenced from XAML or C# with a .png extension.

    Please add the svg file into your MAUI project, and set the build action to MauiImage, then set teh source for the Image.

    For example, I add a pantssvgrepocom.svg file in my project, and use it like the following:

    <Image
         Source="pantssvgrepocom.png"
         ... />
    

    For more details, please refer to Add images to a .NET MAUI app project - .NET MAUI | Microsoft Learn

    Best Regards,

    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    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.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.