2

I am not sure if it is just me, or everyone else out there, but every time i debug my Xamarin app on my mobile device i get a blank screen with an actionbar. The screen is displayed for about 2 seconds before it actually loads my specified screen.

Here is my PCL App.cs file:

public class App : Application
{
    public App()
    {
        // The root page of your application
        MainPage = new LogInPage();
    }

    protected override void OnStart()
    {
        // Handle when your app starts
    }

    protected override void OnSleep()
    {
        // Handle when your app sleeps
    }

    protected override void OnResume()
    {
        // Handle when your app resumes
    }
}

The blank screen:

enter image description here

and then finally, after a few seconds:

enter image description here

Plac3Hold3r
  • 5,062
  • 1
  • 16
  • 21
stoic
  • 4,700
  • 13
  • 58
  • 88

1 Answers1

3

What you are seeing is the default theme of the Activity being shown while Xamarin Forms is being initialized. You will tend to see this during a cold start. One way to work around it is to add a Splash Screen to show during initialization (Xamarin Android Splash Screen doc).

Plac3Hold3r
  • 5,062
  • 1
  • 16
  • 21
  • Or you could append a layout to show instead of the splash screen. – Zverev Evgeniy May 11 '16 at 17:17
  • @ZverevEugene, where would one do that? – stoic May 11 '16 at 18:23
  • @ZverevEugene I would not suggest using a layout over a theme background based splash screen, due to the fact that it takes longer to inflate a layout. Here is a nice post [Splash Screens the Right Way by Chris Stewart](https://www.bignerdranch.com/blog/splash-screens-the-right-way/) explaing the benefits. – Plac3Hold3r May 11 '16 at 18:40
  • @PlaceHold3r This is a questionable statement. So-so modern devices (launched up to 5 years ago) have no problem using layouts as splash-screens at all. Layout really saves app package size (several MBs) compared to all the images one would have to provide for all the possible HDPIs. – Zverev Evgeniy May 11 '16 at 18:49
  • @DustyRoberts There is a layout designer built both into Xamarin for Visual Studio and Xamarin Studio. Start here: http://stackoverflow.com/questions/5486789/how-do-i-make-a-splash-screen – Zverev Evgeniy May 11 '16 at 18:51
  • @ZverevEugene, using a splash screen via the theme will always be quicker (executes earlier in the app life cycle) even it only fractions of a second. Additionally, it never runs the risk of flashing the user with a default themed activity if for whatever reason their device is running slow to inflate the layout. In terms of increasing the size of the package, if done right using a theme background will require no additional image resources than if done via a layout with a single image logo i.e. center image logo and apply a colour background to fill the screen (1 image for each dpi). – Plac3Hold3r May 11 '16 at 19:26