Added in API level 31

SplashScreenView


class SplashScreenView : FrameLayout
kotlin.Any
   ↳ 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.

Summary

Inherited XML attributes
Inherited constants
Public methods
Duration?

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

Instant?

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

View?

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

Unit

Remove this view and release its resource.

Unit
setAlpha(alpha: Float)

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
Unit

Unit
onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int)

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

Inherited functions
Inherited properties

Public methods

getIconAnimationDuration

Added in API level 31
fun getIconAnimationDuration(): Duration?

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

getIconAnimationStart

Added in API level 31
fun getIconAnimationStart(): Instant?

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

Return
Instant? This value may be null.

getIconView

Added in API level 31
fun getIconView(): View?

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

Return
View? This value may be null.

remove

Added in API level 31
fun remove(): Unit

Remove this view and release its resource.

Do not invoke this method from a drawing method (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
fun setAlpha(alpha: Float): Unit

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 android.os.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 android.os.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 android.os.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 android.os.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.0f and 1.0f inclusive

Protected methods

onDetachedFromWindow

protected fun onDetachedFromWindow(): Unit

onLayout

Added in API level 31
protected fun onLayout(
    changed: Boolean,
    l: Int,
    t: Int,
    r: Int,
    b: Int
): Unit

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
left Left position, relative to parent
top Top position, relative to parent
right Right position, relative to parent
bottom Bottom position, relative to parent