0

I've looked at other posts on how to do this but still can't get this to work. I've implemented my splash screen as a background theme and want to fade it as it's dismissing into the main activity. Below is my code currently but the fade isn't working.

splash_background.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <color android:color="#FFF"/>
    </item>
    <item android:gravity="center">
        <vector xmlns:android="http://schemas.android.com/apk/res/android"
            android:width="190dp"
            android:height="190dp"
            android:viewportWidth="108"
            android:viewportHeight="108">
            <path
                android:pathData="M71.07,46.15l1.23,-9.8L40.73,36.35L39.5,46.15ZM70.6,49.88L39,49.88l-2.69,21.4L67.9,71.28L69.07,62L49.3,62l0.51,-4L69.58,58Z"
                android:fillColor="@color/espn_red"/>
        </vector>
    </item>
</layer-list>

fade_out.xml

<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/accelerate_interpolator"
    android:fromAlpha="1.0" android:toAlpha="0.0"
    android:fillAfter="true"
    android:duration="2000" />

themes.xml

<resources xmlns:tools="http://schemas.android.com/tools">
    <!-- Base application theme. -->
    <style name="Theme.SimpleSplash" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
        <!-- Primary brand color. -->
        <item name="colorPrimary">@color/purple_500</item>
        <item name="colorPrimaryVariant">@color/purple_700</item>
        <item name="colorOnPrimary">@color/white</item>
        <!-- Secondary brand color. -->
        <item name="colorSecondary">@color/teal_200</item>
        <item name="colorSecondaryVariant">@color/teal_700</item>
        <item name="colorOnSecondary">@color/black</item>
        <!-- Status bar color. -->
        <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
        <!-- Customize your theme here. -->
    </style>
    <style name="SplashTheme" parent ="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowBackground">@drawable/splash_background</item>
        <item name="android:windowAnimationStyle">@style/SplashTheme.WindowTransition</item>
    </style>
    <!-- Setting window animation -->
    <style name="SplashTheme.WindowTransition">
        <item name="android:windowExitAnimation">@android:anim/fade_out</item>
    </style>
</resources>
Suds
  • 125
  • 2
  • 9
  • Does this answer your question? [How to perform a fade animation on Activity transition?](https://stackoverflow.com/questions/18475826/how-to-perform-a-fade-animation-on-activity-transition) – Lalit Fauzdar Jul 28 '21 at 18:54
  • Hm if I don't want the next activity to fade in (just appear) then I can set fromAlpha to 1.0 instead of 0.0, but is there a cleaner way to do this fade that doesn't require extra code? – Suds Jul 28 '21 at 19:58
  • If you don't want the next activity to fade in, you can see [this answer](https://stackoverflow.com/a/48820855/8244632) of that question, create a theme for SplashActivity and set its exit animation only, no extra code needed, just the theme. – Lalit Fauzdar Jul 28 '21 at 20:35
  • @LalitFauzdar neither implementation from that thread creates a fade, I'm not sure why – Suds Jul 28 '21 at 20:50

0 Answers0