Splash Screen With Image and Text

CiroORICCiroORIC BRMember ✭✭

Hi there!

I'm trying to create a splash screen with image and text.

There are several samples on the net. I'm trying to reproduce some of them with no success. I only got blank screen.

My device is running SANSUNG Android 6.0.1

My code is:

THEME (file ... Resources\values\styles.xml)

LAYOUT (file ... Resources\layout\splash_screen_text.xml)

ACTIVITY (file SplashScreenTextActivity.cs)

Any idea?

Best Answer

Answers

  • JarvanJarvan Member, Xamarin Team Xamurai

    I'm trying to reproduce some of them with no success. I only got blank screen.

    Because you didn't specify the windowBackground in style.xml. You need to create a drawable for splash screen and implement a theme.
    style.xml

    <style name="MyTheme.Splash" parent ="Theme.AppCompat.Light.NoActionBar">
      <item name="android:windowBackground">@drawable/splash_screen</item>
      ...
    </style>
    

    drawable\splash_screen.xml

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

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

  • CiroORICCiroORIC BRMember ✭✭

    Jarvan, thanks to reply.

    Note, I'm not using layer-list as layout for splash screen. I using LinearLayout because I need to put image and text in my splash screen.

    Any suggestion?

  • CiroORICCiroORIC BRMember ✭✭

    After add the task "SimulateStartup" the problem was solved.

    I was calling StartActivity(new Intent(Application.Context, typeof(MainActivity))); not as as Task.

    Thank you Jarvan!

Sign In or Register to comment.