Splash Screen on Android

Hi!

I’m just playing a bit to try to get and Splash Screen working on Android. This is my approach (Based on a similar splash screen that works on NativeScript):

  1. Modify the styles.xml on the build/Android/Debug//app/src/main/res/styles.xml
<resources>
  <style name="ApplicationTheme" parent="@android:style/Theme.Holo">

	</style>

  <style name="SplashScrTheme" parent="ApplicationTheme">
          <item name="android:windowActionBar">false</item>
          <item name="android:windowNoTitle">true</item>
          <item name="android:windowContentOverlay">@null</item>
          <item name="android:windowBackground">@drawable/splashscreen</item>
      </style>

	<style name="AppTheme" parent="ApplicationTheme">
		<item name="android:windowIsTranslucent">true</item>
		<item name="android:windowBackground">@android:color/transparent</item>
	</style>

</resources>
  1. Modify the build/Android/Debug//app/src/main/AndroidManifest.xml file to use the SplashScrTheme
        <activity android:name="splashsample"
                  android:label="splash-sample"
                  android:launchMode="singleTask"
                  android:theme="@style/SplashScrTheme"
                  android:taskAffinity=""
                  android:windowSoftInputMode="adjustResize"
                  android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize"
                  android:screenOrientation="portrait"
                  android:windowActionBar="false">
  1. Modify the build/Android/Debug//app/src/main/java/com/apps//.java on the onCreate method
   @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        // mandatory call to super
        super.onCreate(savedInstanceState);
        fuseApp.onCreate(savedInstanceState);
        setTheme(android.R.style.AppTheme);
    }

The idea is that instead of a transparent window, show a screen with a background image as splash and when the activity is created, change the theme.

The problem is that every time i build, the changes made reverted to default. Any idea about how can i test this idea?

Regards

John

PS: I get my “inspiration” on this article: https://www.nativescript.org/blog/splash-screen-for-your-android-applications

I might misunderstand what you are trying to achieve, but there are several threads on creating a splash screen in pure Fuse without modifying the build files, such as the “Hikr” tutorial in our Docs-section as well as this: https://www.fusetools.com/community/forums/howto_discussions/how_do_i_create_a_splashscreen?page=1&highlight=6d5de86a-c042-4bab-85b6-8751f8b995a0#post-6d5de86a-c042-4bab-85b6-8751f8b995a0

Hi!

Thanks! I read the tutorial, and yes, it works, and tried it, but it;s intended to show a splash for x secconds, no matter how long takes to load the app, and it shows only when the app is loaded. It’s only a delay.

My approach is different and exclusive of Android. On iOS the Splash Screen is easy to show a splash while the App is loading. I want to do something like this on Android.

I notice that when app loads on Android, the default theme shows an transparent screen:

    <style name="AppTheme" parent="ApplicationTheme">
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
    </style>

My idea is to default set the theme to a splash theme, and when the Activity loads, change the theme to the default. So, when the app loads it shows a logo or something.

Regards

Jonatan

Ah, then I get what you are asking for. :slight_smile: It is indeed very simple on iOS (it’s called “Launch image” and you set it directly in Xcode). AFAIK, Android does not come with such an option (or at least it didn’t use to at least), and it doesn’t seem to be a part of the design guidelines either.

TL;DR: sorry I couldn’t be of more help. Your idea might indeed work, but yes, it looks like it’ll involve hacking on the files on each build.

For many my Android apps i use this tutorial, short and simple Splash screen on Android

  1. styles.xml
<resources>
    <style name="AppTheme" parent="@style/Theme.AppCompat.Light">
        <item name="windowNoTitle">true</item>
        <item name="android:windowIsTranslucent">false</item>
        <item name="android:windowBackground">@drawable/background_splash</item>
    </style>
</resources>
  1. background_splash.xml (Replace android:src="@mipmap/icon" with your value)
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:drawable="@color/white"/>
    <item>
        <bitmap
            android:gravity="center"
            android:src="@mipmap/icon"/>
    </item>
</layer-list>
  1. colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="white">#FFFFFF</color>
</resources>
  1. Splash.uxl
<Extensions Backend="CPlusPlus" Condition="Android">
    <CopyFile Name="background_splash.xml" TargetName="app/src/main/res/drawable/background_splash.xml" />
    <CopyFile Name="styles.xml" TargetName="app/src/main/res/values/styles.xml" />
    <CopyFile Name="colors.xml" TargetName="app/src/main/res/values/colors.xml" />
</Extensions>
2 Likes