Visibility

abstract class Visibility : Transition
kotlin.Any
   ↳ androidx.transition.Transition
   ↳ androidx.transition.Visibility

This transition tracks changes to the visibility of target views in the start and end scenes. Visibility is determined not just by the View#setVisibility(int) state of views, but also whether views exist in the current view hierarchy. The class is intended to be a utility for subclasses such as Fade, which use this visibility information to determine the specific animations to run when visibility changes occur. Subclasses should implement one or both of the methods onAppear(ViewGroup, TransitionValues, int, TransitionValues, int), onDisappear(ViewGroup, TransitionValues, int, TransitionValues, int) or onAppear(ViewGroup, View, TransitionValues, TransitionValues), onDisappear(ViewGroup, View, TransitionValues, TransitionValues).

Summary

Constants

static Int

Mode used in setMode(int) to make the transition operate on targets that are appearing.

static Int

Mode used in setMode(int) to make the transition operate on targets that are disappearing.

Inherited constants

Public constructors

<init>(context: Context!, attrs: AttributeSet!)

Public methods

open Unit
captureEndValues(@NonNull transitionValues: TransitionValues)

open Unit
captureStartValues(@NonNull transitionValues: TransitionValues)

open Animator?
createAnimator(@NonNull sceneRoot: ViewGroup, @Nullable startValues: TransitionValues?, @Nullable endValues: TransitionValues?)

open Int

Returns whether appearing and/or disappearing Views are supported.

open Array<String!>?

open Boolean

open Boolean

Returns whether the view is 'visible' according to the given values object.

open Animator!
onAppear(sceneRoot: ViewGroup!, startValues: TransitionValues!, startVisibility: Int, endValues: TransitionValues!, endVisibility: Int)

The default implementation of this method does nothing.

open Animator!
onAppear(sceneRoot: ViewGroup!, view: View!, startValues: TransitionValues!, endValues: TransitionValues!)

The default implementation of this method returns a null Animator.

open Animator!
onDisappear(sceneRoot: ViewGroup!, startValues: TransitionValues!, startVisibility: Int, endValues: TransitionValues!, endVisibility: Int)

The default implementation of this method does nothing.

open Animator!
onDisappear(sceneRoot: ViewGroup!, view: View!, startValues: TransitionValues!, endValues: TransitionValues!)

The default implementation of this method returns a null Animator.

open Unit
setMode(mode: Int)

Changes the transition to support appearing and/or disappearing Views, depending on mode.

Inherited functions

Constants

MODE_IN

static val MODE_IN: Int

Mode used in setMode(int) to make the transition operate on targets that are appearing. Maybe be combined with MODE_OUT to target Visibility changes both in and out.

Value: 0x1

MODE_OUT

static val MODE_OUT: Int

Mode used in setMode(int) to make the transition operate on targets that are disappearing. Maybe be combined with MODE_IN to target Visibility changes both in and out.

Value: 0x2

Public constructors

<init>

Visibility()

<init>

Visibility(context: Context!, attrs: AttributeSet!)

Public methods

captureEndValues

open fun captureEndValues(@NonNull transitionValues: TransitionValues): Unit

captureStartValues

open fun captureStartValues(@NonNull transitionValues: TransitionValues): Unit

createAnimator

@Nullable open fun createAnimator(@NonNull sceneRoot: ViewGroup, @Nullable startValues: TransitionValues?, @Nullable endValues: TransitionValues?): Animator?

getMode

open fun getMode(): Int

Returns whether appearing and/or disappearing Views are supported.

Return
Int: whether appearing and/or disappearing Views are supported. A combination of MODE_IN and MODE_OUT.

getTransitionProperties

@Nullable open fun getTransitionProperties(): Array<String!>?

isTransitionRequired

open fun isTransitionRequired(startValues: TransitionValues?, newValues: TransitionValues?): Boolean

isVisible

open fun isVisible(values: TransitionValues!): Boolean

Returns whether the view is 'visible' according to the given values object. This is determined by testing the same properties in the values object that are used to determine whether the object is appearing or disappearing in the method. This method can be called by, for example, subclasses that want to know whether the object is visible in the same way that Visibility determines it for the actual animation.

Parameters
values TransitionValues!: The TransitionValues object that holds the information by which visibility is determined.
Return
Boolean: True if the view reference by values is visible, false otherwise.

onAppear

open fun onAppear(sceneRoot: ViewGroup!, startValues: TransitionValues!, startVisibility: Int, endValues: TransitionValues!, endVisibility: Int): Animator!

The default implementation of this method does nothing. Subclasses should override if they need to create an Animator when targets appear. The method should only be called by the Visibility class; it is not intended to be called from external classes.

Parameters
sceneRoot ViewGroup!: The root of the transition hierarchy
startValues ViewGroup!: The target values in the start scene
startVisibility ViewGroup!: The target visibility in the start scene
endValues ViewGroup!: The target values in the end scene
endVisibility ViewGroup!: The target visibility in the end scene
Return
Animator!: An Animator to be started at the appropriate time in the overall transition for this scene change. A null value means no animation should be run.

onAppear

open fun onAppear(sceneRoot: ViewGroup!, view: View!, startValues: TransitionValues!, endValues: TransitionValues!): Animator!

The default implementation of this method returns a null Animator. Subclasses should override this method to make targets appear with the desired transition. The method should only be called from onAppear(ViewGroup, TransitionValues, int, TransitionValues, int).

Parameters
sceneRoot ViewGroup!: The root of the transition hierarchy
view ViewGroup!: The View to make appear. This will be in the target scene's View hierarchy and will be VISIBLE.
startValues ViewGroup!: The target values in the start scene
endValues ViewGroup!: The target values in the end scene
Return
Animator!: An Animator to be started at the appropriate time in the overall transition for this scene change. A null value means no animation should be run.

onDisappear

open fun onDisappear(sceneRoot: ViewGroup!, startValues: TransitionValues!, startVisibility: Int, endValues: TransitionValues!, endVisibility: Int): Animator!

The default implementation of this method does nothing. Subclasses should override if they need to create an Animator when targets disappear. The method should only be called by the Visibility class; it is not intended to be called from external classes.

Parameters
sceneRoot ViewGroup!: The root of the transition hierarchy
startValues ViewGroup!: The target values in the start scene
startVisibility ViewGroup!: The target visibility in the start scene
endValues ViewGroup!: The target values in the end scene
endVisibility ViewGroup!: The target visibility in the end scene
Return
Animator!: An Animator to be started at the appropriate time in the overall transition for this scene change. A null value means no animation should be run.

onDisappear

open fun onDisappear(sceneRoot: ViewGroup!, view: View!, startValues: TransitionValues!, endValues: TransitionValues!): Animator!

The default implementation of this method returns a null Animator. Subclasses should override this method to make targets disappear with the desired transition. The method should only be called from onDisappear(ViewGroup, TransitionValues, int, TransitionValues, int).

Parameters
sceneRoot ViewGroup!: The root of the transition hierarchy
view ViewGroup!: The View to make disappear. This will be in the target scene's View hierarchy or in an android.view.ViewGroupOverlay and will be VISIBLE.
startValues ViewGroup!: The target values in the start scene
endValues ViewGroup!: The target values in the end scene
Return
Animator!: An Animator to be started at the appropriate time in the overall transition for this scene change. A null value means no animation should be run.

setMode

open fun setMode(mode: Int): Unit

Changes the transition to support appearing and/or disappearing Views, depending on mode.

Parameters
mode Int: The behavior supported by this transition, a combination of MODE_IN and MODE_OUT.