SplashScreenView


public final class SplashScreenView
extends FrameLayout

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ android.window.SplashScreenView


The view which allows an activity to customize its splash screen exit animation.

Activities will receive this view as a parameter of SplashScreen.OnExitAnimationListener#onSplashScreenExit if they set SplashScreen#setOnExitAnimationListener. When this callback is called, this view will be on top of the activity.

This view is composed of a view containing the splashscreen icon (see windowSplashscreenAnimatedIcon) and a background. Developers can use getIconView() to get this view and replace the drawable or add animation to it. The background of this view is filled with a single color, which can be edited during the animation by View#setBackground or View#setBackgroundColor.

See also:

Summary

Inherited XML attributes

Inherited constants

Inherited fields

Public methods

Duration getIconAnimationDuration()

Returns the duration of the icon animation if icon is animatable.

Instant getIconAnimationStart()

If the replaced icon is animatable, return the animation start time based on system clock.

View getIconView()

Get the view containing the Splash Screen icon and its background.

void remove()

Remove this view and release its resource.

void setAlpha(float alpha)

Sets the opacity of the view to a value from 0 to 1, where 0 means the view is completely transparent and 1 means the view is completely opaque.

Protected methods

void onLayout(boolean changed, int l, int t, int r, int b)

Called from layout when this view should assign a size and position to each of its children.

Inherited methods

Public methods

getIconAnimationDuration

Added in API level 31
public Duration getIconAnimationDuration ()

Returns the duration of the icon animation if icon is animatable. Note the return value can be null or 0 if the R.attr.windowSplashScreenAnimatedIcon is not AnimationDrawable or AnimatedVectorDrawable.

Returns
Duration

getIconAnimationStart

Added in API level 31
public Instant getIconAnimationStart ()

If the replaced icon is animatable, return the animation start time based on system clock.

Returns
Instant This value may be null.

getIconView

Added in API level 31
public View getIconView ()

Get the view containing the Splash Screen icon and its background.

Returns
View This value may be null.

remove

Added in API level 31
public void remove ()

Remove this view and release its resource.

Do not invoke this method from a drawing method (View.onDraw(android.graphics.Canvas) for instance).


This method must be called on the thread that originally created this UI element. This is typically the main thread of your app.

setAlpha

Added in API level 31
public void setAlpha (float alpha)

Sets the opacity of the view to a value from 0 to 1, where 0 means the view is completely transparent and 1 means the view is completely opaque.

Note: setting alpha to a translucent value (0 < alpha < 1) can have significant performance implications, especially for large views. It is best to use the alpha property sparingly and transiently, as in the case of fading animations.

For a view with a frequently changing alpha, such as during a fading animation, it is strongly recommended for performance reasons to either override hasOverlappingRendering() to return false if appropriate, or setting a layer type on the view for the duration of the animation. On versions Build.VERSION_CODES.M and below, the default path for rendering an unlayered View with alpha could add multiple milliseconds of rendering cost, even for simple or small views. Starting with Build.VERSION_CODES.M, LAYER_TYPE_HARDWARE is automatically applied to the view at the rendering level.

If this view overrides onSetAlpha(int) to return true, then this view is responsible for applying the opacity itself.

On versions Build.VERSION_CODES.LOLLIPOP_MR1 and below, note that if the view is backed by a layer and is associated with a layer paint, setting an alpha value less than 1.0 will supersede the alpha of the layer paint.

Starting with Build.VERSION_CODES.M, setting a translucent alpha value will clip a View to its bounds, unless the View returns false from hasOverlappingRendering().

Parameters
alpha float: The opacity of the view. Value is between 0.0 and 1.0 inclusive

Protected methods

onLayout

Added in API level 31
protected void onLayout (boolean changed, 
                int l, 
                int t, 
                int r, 
                int b)

Called from layout when this view should assign a size and position to each of its children. Derived classes with children should override this method and call layout on each of their children.

Parameters
changed boolean: This is a new size or position for this view

l int: Left position, relative to parent

t int: Top position, relative to parent

r int: Right position, relative to parent

b int: Bottom position, relative to parent