0

My company has a single activity Android Kotlin applicaiton.
We would like to display a splashscreen on startup.
After reading a bunch of turtorial I have found a way to do it.
But when I try to display an ImageView the splashscreen, it becomes a white background.

Here is my code:

AndroidManifest.xml

<application
    ...
    android:theme="@style/Theme.SplashScreen">
    ...
</application

Theme.SplashScreen in res/values/themes/themes.xml

<resources xmlns:tools="http://schemas.android.com/tools">
    ...
    <style name="Theme.SplashScreen" parent="Theme.AppCompat.NoActionBar">
        <item name="android:windowBackground">@drawable/splash_background</item>
    </style>
    ...
</resources>

res/drawable/splash_background.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <item android:drawable="@color/blue" />
    <item>

        <!-- This works
        <bitmap
            android:gravity="center"
            android:src="@mipmap/ic_launcher" />
        -->
        <!-- This doesn't work --> 
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="250dp"
            android:src="@drawable/ic_somePicture"
            app:tint="@color/white" />
    </item>
</layer-list>

Notice I have two cases here: The bitmap and the ImageView cases.

  • The bitmap case work if I uncomment it.
    During startup this image is displayed in the splashscreen.
  • The ImageView case doesn't work.
    This result is a completely white splashscreen.

The ImageView "should" work, because I use the same setup in some fragments.

The @drawable/ic_somePicture is a SVG-image that I have added in the AndroidStudio project.
I cannot show it here, as it's a property of my company.
Notice I have to specify the app:tint property to show the image on whatever background color I have in either the splash_background.xml or the fragment.

What could be the problem?
Any suggestion how to fix this?

Mc_Topaz
  • 567
  • 1
  • 6
  • 21

1 Answers1

0

I have this setting in my SplashScreen

class MainActivity : AppCompatActivity(){
    private val SPLASH_DISPLAY_LENGTH = 5000
    override fun onCreate(s: Bundle?) {
        super.onCreate(s)
        setContentView(R.layout.welcome)
    }

    override fun onResume() {
        super.onResume()
        Handler().postDelayed({ /* Create an Intent that will start the Menu-Activity. */
            val mainIntent = Intent()
            mainIntent.setClass(applicationContext, MapsActivity::class.java)
            startActivity(mainIntent)
            finish()
        }, SPLASH_DISPLAY_LENGTH.toLong())
    }
}

ImageView

<ImageView
        android:layout_marginTop="80dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:background="@drawable/logo"
        android:id="@+id/image_splash"/>
Ibernato
  • 37
  • 1
  • 9