0
votes

I'm able to display the splash screen with no problem, but I need to provide the correctly sized splash image depending on the screen resolution. In all the examples I've checked, they say to put splashscreen.png into a drawable folder and reference it it in splash.xml which is in turn referenced in a style.xml which is used as the splash activity theme.

splash.xml inside Resources > drawable

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  <item>
    <color android:color="@color/launcher_background"/>
  </item>
  <item>
    <bitmap
        android:src="@drawable/splashscreen"
        android:tileMode="disabled"
        android:gravity="center"
        />
  </item>
</layer-list> 

Inside Resources > values > styles.xml:

<style name="splashscreen" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowBackground">@drawable/splash</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsTranslucent">false</item>
    <item name="android:windowIsFloating">false</item>
    <item name="android:backgroundDimEnabled">true</item>
  </style>

Here is my problem:

There is a drawable folder inside Resources, And there are separate mipmap folders inside Resources which are supposed to home the different sizes for splash screens. The examples I've seen only reference a single image from drawable. So the question is, how do I appropriately reference the correct splashscreen.png depending on the device resolution?

Sources:

https://docs.microsoft.com/en-us/xamarin/android/user-interface/splash-screen

https://www.xamarinhelp.com/creating-splash-screen-xamarin-forms/

1
The device itself grabs it from the correct folder, you will need to provide the appropriate image asset for each folder. In other words you will need multiples of the same image which have the appropriate resolution for mdpi, xdpi,xxdpi, etc.SomeStudent
Yes but how??...I have to reference the splash.png in splash.xml. that is pointing only to a single png file in drawable.David Andrew Thorpe
So you will need to make the same file in different resolutions, usually a designer does that, but as far as referencing it, it is still the same name. So you will have spalsh.png , for example, in your drawable, and in all the other layout folders. The platform itself will know where to lookSomeStudent
Are you saying that I should put the splash.xml file inside the drawable folder, and then all the splashscreen.png files inside their respective folder sizes?David Andrew Thorpe
the xml file can stay where it is, you just need to put the splashscreen.png in its respective folder sizeSomeStudent

1 Answers

1
votes

Image needs to be referenced only from drawable folder and other folders should have the images with exact same name. Based on the resolution device automatically picks the correct drawable folder and image inside it. For more details Click here