Forum Xamarin.Android

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Purpose of launcher_foreground.png

SteeveSteeve Member ✭✭

Hi,

I'm currently trying to understand what is the purpose of the launcher_foreground.png file in mipmap folders.
I have set my application icon through icon property but I don't understand what do I have to do with the second file and can't find any documentation about it.
When I launch my app, the actual image doesn't show anywhere so I'm curious about it.

Can anyone explain what is the purpose of launcher_foreground please ?
Thanks

Best Answer

Answers

  • LeonLuLeonLu Member, Xamarin Team Xamurai

    what is the purpose of the launcher_foreground.png file in mipmap folders?

    You can open your Android project folder like this screenshot.

    Please open icon.xml, you can see following code.

    <?xml version="1.0" encoding="utf-8"?>
    <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
        <background android:drawable="@color/launcher_background" />
        <foreground android:drawable="@mipmap/launcher_foreground" />
    </adaptive-icon>
    

    Your launcher_foreground.png was used here.

    If I put my myIcon.png to every mipmap folders.

    Then I change the code in the icon.xml

    <?xml version="1.0" encoding="utf-8"?>
    <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
        <background android:drawable="@color/launcher_background" />
        <foreground android:drawable="@mipmap/myIcon" />
    </adaptive-icon>
    

    My application icon will be changed to myIcon.png.

    To support different pixel densities. Android devices come in different screen sizes(such as handsets, tablets, TVs, and so on)) their screens also have different pixel sizes. If you don't consider these variations in pixel density, the system might scale your images or the images might appear at the completely wrong size.

    To provide good graphical qualities on devices with different pixel densities, you should provide multiple versions of each bitmap in your app—one for each density bucket, at a corresponding resolution. Put your image in different mipmap folders like following screenshot.

    You can see this thread:

    https://developer.android.com/training/multiscreen/screendensities.html#TaskProvideAltBmp

  • LeonLuLeonLu Member, Xamarin Team Xamurai

    @Steeve Are there any update for this issue? If reply is helpful, please accept it as answer, it will help others who have similar issue.

  • SteeveSteeve Member ✭✭

    Hi LeonLu (and nice pic Mr White ;) )

    I already knew about that but I think I understand a little bit more what is confusing me :

    first : If I understood well the behavior, AndroidManifest override this setting. In fact I already have set my app Icon using Project Properties and it's ok, it works with the applied icon.
    the second thing is that I have compared the two default pictures in the mipmap folders. One picture is the standard icon, that's ok for me, the other is the same Xamarin logo but with a white rectangular background. I don't understand the purpose of this picture.

  • SteeveSteeve Member ✭✭

    Many thanks, that's crystal clear !

Sign In or Register to comment.