# MaterialSharedAxis

[View Source](https://github.com/material-components/material-components-android/blob/1.14.0/lib/java/com/google/android/material/transition/MaterialSharedAxis.java)

*** ** * ** ***


```
public final class MaterialSharedAxis
```

<br />

*** ** * ** ***

A androidx.transition.Visibility transition that provides shared motion along an axis.

When configured along the `https://developer.android.com/reference/com/google/android/material/transition/MaterialSharedAxis#X()` axis, this transition slides and fades in the target when appearing and slides and fades out the target when disappearing.

When configured along the `https://developer.android.com/reference/com/google/android/material/transition/MaterialSharedAxis#Y()` axis, this transition slides and fades in the target when appearing and slides and fades out the target when disappearing.

When configured along the `https://developer.android.com/reference/com/google/android/material/transition/MaterialSharedAxis#Z()` axis, this transition scales and fades in when the target is appearing and scales and fades out when the target is disappearing.

The direction of the slide or scale is determined by the constructors's forward property. When true, the target will slide to the left on the X axis, up on the Y axis and out in on the Z axis. When false, the target will slide to the right on the X axis, down on the Y axis and in on the Z axis. Note that this is independent of whether or not the target is appearing or disappearing.

MaterialSharedAxis supports theme-based easing and duration. The transition will load theme values from the `SceneRoot`'s context before it runs, and only use them if the corresponding properties weren't already set on the transition instance.

## Summary

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialSharedAxis#X() = 0` Indicates that the x-axis should be shared for the transition, meaning a horizontal slide and fade should be used. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialSharedAxis#Y() = 1` Indicates that the y-axis should be shared for the transition, meaning a vertical slide and fade should be used. |
| `static final int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialSharedAxis#Z() = 2` Indicates that the z-axis should be shared for the transition, meaning a scale and fade should be used. |

| ### Public fields |
|---|---|
| `final int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialSharedAxis#axis()` |
| `final P` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialSharedAxis#primaryAnimatorProvider()` |
| `https://developer.android.com/reference/com/google/android/material/transition/VisibilityAnimatorProvider` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialSharedAxis#secondaryAnimatorProvider()` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialSharedAxis#MaterialSharedAxis(int,boolean)(int axis, boolean forward)` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialSharedAxis#addAdditionalAnimatorProvider(com.google.android.material.transition.VisibilityAnimatorProvider)( https://developer.android.com/reference/com/google/android/material/transition/VisibilityAnimatorProvider additionalAnimatorProvider )` Adds an additional `https://developer.android.com/reference/com/google/android/material/transition/VisibilityAnimatorProvider`, which provides animators be played together with the primary and secondary `https://developer.android.com/reference/com/google/android/material/transition/VisibilityAnimatorProvider`. |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialSharedAxis#clearAdditionalAnimatorProvider()()` Clears all additional `https://developer.android.com/reference/com/google/android/material/transition/VisibilityAnimatorProvider` that were previously added. |
| `int` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialSharedAxis#getAxis()()` |
| `P` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialSharedAxis#getPrimaryAnimatorProvider()()` Returns the primary `https://developer.android.com/reference/com/google/android/material/transition/VisibilityAnimatorProvider` for this transition, which can be modified but not swapped out completely. |
| `https://developer.android.com/reference/com/google/android/material/transition/VisibilityAnimatorProvider` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialSharedAxis#getSecondaryAnimatorProvider()()` Returns the secondary `https://developer.android.com/reference/com/google/android/material/transition/VisibilityAnimatorProvider` for this transition or null, which can be modified or swapped out completely for a different `https://developer.android.com/reference/com/google/android/material/transition/VisibilityAnimatorProvider`. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialSharedAxis#isForward()()` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialSharedAxis#isSeekingSupported()()` |
| `Animator` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialSharedAxis#onAppear(ViewGroup,View,TransitionValues,TransitionValues)( ViewGroup sceneRoot, View view, TransitionValues startValues, TransitionValues endValues )` |
| `Animator` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialSharedAxis#onDisappear(ViewGroup,View,TransitionValues,TransitionValues)( ViewGroup sceneRoot, View view, TransitionValues startValues, TransitionValues endValues )` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialSharedAxis#removeAdditionalAnimatorProvider(com.google.android.material.transition.VisibilityAnimatorProvider)( https://developer.android.com/reference/com/google/android/material/transition/VisibilityAnimatorProvider additionalAnimatorProvider )` Removes an additional `https://developer.android.com/reference/com/google/android/material/transition/VisibilityAnimatorProvider` that was previously added. |
| `void` | `https://developer.android.com/reference/com/google/android/material/transition/MaterialSharedAxis#setSecondaryAnimatorProvider(com.google.android.material.transition.VisibilityAnimatorProvider)( https://developer.android.com/reference/com/google/android/material/transition/VisibilityAnimatorProvider secondaryAnimatorProvider )` Sets the secondary `https://developer.android.com/reference/com/google/android/material/transition/VisibilityAnimatorProvider`, which provides animators to be played together with the primary `https://developer.android.com/reference/com/google/android/material/transition/VisibilityAnimatorProvider`. |

## Constants

### X

```
public static final int X = 0
```

Indicates that the x-axis should be shared for the transition, meaning a horizontal slide and fade should be used.

In the forward direction, targets of this transition will slide left.

### Y

```
public static final int Y = 1
```

Indicates that the y-axis should be shared for the transition, meaning a vertical slide and fade should be used.

In the forward direction, targets of this transition will slide up.

### Z

```
public static final int Z = 2
```

Indicates that the z-axis should be shared for the transition, meaning a scale and fade should be used.

In the forward direction, targets of this transition will scale out.

## Public fields

### axis

```
public final int axis
```

### primaryAnimatorProvider

```
public final P primaryAnimatorProvider
```

### secondaryAnimatorProvider

```
public VisibilityAnimatorProvider secondaryAnimatorProvider
```

## Public constructors

### MaterialSharedAxis

```
public MaterialSharedAxis(int axis, boolean forward)
```

## Public methods

### addAdditionalAnimatorProvider

```
public void addAdditionalAnimatorProvider(
    VisibilityAnimatorProvider additionalAnimatorProvider
)
```

Adds an additional `https://developer.android.com/reference/com/google/android/material/transition/VisibilityAnimatorProvider`, which provides animators be played together with the primary and secondary `https://developer.android.com/reference/com/google/android/material/transition/VisibilityAnimatorProvider`.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialVisibility#getPrimaryAnimatorProvider()` |   |
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialVisibility#getSecondaryAnimatorProvider()` |   |

### clearAdditionalAnimatorProvider

```
public void clearAdditionalAnimatorProvider()
```

Clears all additional `https://developer.android.com/reference/com/google/android/material/transition/VisibilityAnimatorProvider` that were previously added.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialVisibility#addAdditionalAnimatorProvider(com.google.android.material.transition.VisibilityAnimatorProvider)` |   |

### getAxis

```
public int getAxis()
```

### getPrimaryAnimatorProvider

```
public P getPrimaryAnimatorProvider()
```

Returns the primary `https://developer.android.com/reference/com/google/android/material/transition/VisibilityAnimatorProvider` for this transition, which can be modified but not swapped out completely.

### getSecondaryAnimatorProvider

```
public VisibilityAnimatorProvider getSecondaryAnimatorProvider()
```

Returns the secondary `https://developer.android.com/reference/com/google/android/material/transition/VisibilityAnimatorProvider` for this transition or null, which can be modified or swapped out completely for a different `https://developer.android.com/reference/com/google/android/material/transition/VisibilityAnimatorProvider`.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialVisibility#setSecondaryAnimatorProvider(com.google.android.material.transition.VisibilityAnimatorProvider)` |   |

### isForward

```
public boolean isForward()
```

### isSeekingSupported

```
public boolean isSeekingSupported()
```

### onAppear

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

### onDisappear

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

### removeAdditionalAnimatorProvider

```
public boolean removeAdditionalAnimatorProvider(
    VisibilityAnimatorProvider additionalAnimatorProvider
)
```

Removes an additional `https://developer.android.com/reference/com/google/android/material/transition/VisibilityAnimatorProvider` that was previously added.

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/transition/MaterialVisibility#addAdditionalAnimatorProvider(com.google.android.material.transition.VisibilityAnimatorProvider)` |   |

### setSecondaryAnimatorProvider

```
public void setSecondaryAnimatorProvider(
    VisibilityAnimatorProvider secondaryAnimatorProvider
)
```

Sets the secondary `https://developer.android.com/reference/com/google/android/material/transition/VisibilityAnimatorProvider`, which provides animators to be played together with the primary `https://developer.android.com/reference/com/google/android/material/transition/VisibilityAnimatorProvider`.