How to set Splash Screen image from API?

I need to set Splash Screen image from API. But images in style we can only set from Resources/drawable and resource folder are readonly, we can't change it from code.
Maybe do you know other solution?

Answers

  • JarvanJarvan Member, Xamarin Team Xamurai

    How did you set up the splash screen? Simply change the source of the image in the background_drawable xml file.

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

    Check the tutorial:
    https://raulmonteroc.com/xamarin/setup-splash-screen-xamarin-forms/

  • FeduniakVFeduniakV Member ✭✭

    @Jarvan said:
    How did you set up the splash screen? Simply change the source of the image in the background_drawable xml file.

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

    Check the tutorial:
    https://raulmonteroc.com/xamarin/setup-splash-screen-xamarin-forms/

    I did like this, but I need in source use URL or call to API.
    Every device must have own splash screen.

  • JohnHJohnH GBMember ✭✭✭✭✭

    Splash screens on app start must be defined in the app itself, you cannot fetch it.

  • FeduniakVFeduniakV Member ✭✭

    @JohnH said:
    Splash screens on app start must be defined in the app itself, you cannot fetch it.

    Maybe somehow I can change image on resources and on next run app - splash screen will be new ?

  • msdYqbmsdYqb USMember ✭✭

    is it really a good idea to have splash screen from api?
    Ive never seen an app doing that

    remember it takes time to retrieve data from api
    how can you manage that wait time in splash screen?

    my advice to you is do what you want to do in another page after splash screen

    just copy the image to LocalApplicationData and show it from there

Sign In or Register to comment.