9

I am using the newly released Splash Screen API for Android 12, however the animatable vector will not animate. The icon that shows is just a snapshot of the drawable.

I've added this line of code into my themes.xml file:

<item name="android:windowSplashScreenAnimatedIcon">@drawable/sample</item>

sample.xml

<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:aapt="http://schemas.android.com/aapt" >
    <aapt:attr name="android:drawable">
        <vector
            android:height="64dp"
            android:width="64dp"
            android:viewportHeight="600"
            android:viewportWidth="600" >
            <group
                android:name="rotationGroup"
                android:pivotX="300.0"
                android:pivotY="300.0"
                android:rotation="45.0" >
                <path
                    android:name="v"
                    android:fillColor="#000000"
                    android:pathData="M300,70 l 0,-70 70,70 0,0 -70,70z" />
            </group>
        </vector>
    </aapt:attr>

    <target android:name="rotationGroup"> *
        <aapt:attr name="android:animation">
            <objectAnimator
                android:duration="6000"
                android:propertyName="rotation"
                android:valueFrom="0"
                android:valueTo="360" />
        </aapt:attr>
    </target>

    <target android:name="v" >
        <aapt:attr name="android:animation">
            <set>
                <objectAnimator
                    android:duration="3000"
                    android:propertyName="pathData"
                    android:valueFrom="M300,70 l 0,-70 70,70 0,0 -70,70z"
                    android:valueTo="M300,70 l 0,-70 70,0  0,140 -70,0 z"
                    android:valueType="pathType"/>
            </set>
        </aapt:attr>
    </target>
</animated-vector>
 

MainActivity.java

package com.example.simplesplashscreen;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}
Suds
  • 125
  • 2
  • 9
  • post your SplashActivity too – Elango Jun 21 '21 at 17:09
  • posted MainActivity.java but I haven't made modifications to it beyond the default – Suds Jun 21 '21 at 20:31
  • check this out, https://www.journaldev.com/17831/android-splash-screen then working on aminations – Elango Jun 22 '21 at 05:06
  • Thank you however this article is explaining how to implement a splash screen using the traditional way. I am trying to implement it using the newly release Splash Screen API for Android 12 and above https://developer.android.com/about/versions/12/features/splash-screen – Suds Jun 22 '21 at 14:11
  • I also did not seem to make it work. Did you found any solution. – Zakir Sheikh Jan 28 '22 at 04:06

1 Answers1

4

You also need to provide the duration:

If you use the platform API (Android 12+):

<item name="android:windowSplashScreenAnimationDuration">3000</item>

If you use the core-splashscreen library:

<item name="windowSplashScreenAnimationDuration">3000</item>

Note that the animated vector only works on Android 12+

Vadim Caen
  • 1,526
  • 11
  • 21
  • 2
    this doesnt work....Library is probably still in alpha, because animated vector drawable DOES NOT WORK - I literally copy pasted it from Google docs and tried with X animated drawables - nothing works. But normal static icons works fine...Argh, Google. I wish for once I could just read docs, and it would actually work as described :/ – qkx Feb 08 '22 at 10:32
  • more info about people experiencing similar things in this thread: https://stackoverflow.com/questions/69812590/android-12-splash-screen-icon-not-displaying – qkx Feb 08 '22 at 10:38
  • This answer is for the Platform API, not for the libray, in which case you need to remove the `android` prefix. Also AVD work only on Android 12+ – Vadim Caen Feb 09 '22 at 11:32