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?