Visibility

public abstract class Visibility
extends Transition

java.lang.Object
   ↳ 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

int MODE_IN

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

int MODE_OUT

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

Inherited constants

Public constructors

Visibility()
Visibility(Context context, AttributeSet attrs)

Public methods

void captureEndValues(TransitionValues transitionValues)

Captures the values in the end scene for the properties that this transition monitors.

void captureStartValues(TransitionValues transitionValues)

Captures the values in the start scene for the properties that this transition monitors.

Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues)

This method creates an animation that will be run for this transition given the information in the startValues and endValues structures captured earlier for the start and end scenes.

int getMode()

Returns whether appearing and/or disappearing Views are supported.

String[] getTransitionProperties()

Returns the set of property names used stored in the TransitionValues object passed into captureStartValues(TransitionValues) that this transition cares about for the purposes of canceling overlapping animations.

boolean isTransitionRequired(TransitionValues startValues, TransitionValues endValues)

Returns whether or not the transition should create an Animator, based on the values captured during captureStartValues(TransitionValues) and captureEndValues(TransitionValues).

boolean isVisible(TransitionValues values)

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

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

The default implementation of this method returns a null Animator.

Animator onAppear(ViewGroup sceneRoot, TransitionValues startValues, int startVisibility, TransitionValues endValues, int endVisibility)

The default implementation of this method does nothing.

Animator onDisappear(ViewGroup sceneRoot, TransitionValues startValues, int startVisibility, TransitionValues endValues, int endVisibility)

The default implementation of this method does nothing.

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

The default implementation of this method returns a null Animator.

void setMode(int mode)

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

Inherited methods

Constants

MODE_IN

public static final int MODE_IN

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.

Constant Value: 1 (0x00000001)

MODE_OUT

public static final int MODE_OUT

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.

Constant Value: 2 (0x00000002)

Public constructors

Visibility

public Visibility ()

Visibility

public Visibility (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

Public methods

captureEndValues

public void captureEndValues (TransitionValues transitionValues)

Captures the values in the end scene for the properties that this transition monitors. These values are then passed as the endValues structure in a later call to createAnimator(ViewGroup, TransitionValues, TransitionValues). The main concern for an implementation is what the properties are that the transition cares about and what the values are for all of those properties. The start and end values will be compared later during the createAnimator(ViewG