# ParallaxEffect

Artifact: [androidx.leanback:leanback](https://developer.android.com/jetpack/androidx/releases/leanback) [View Source](https://cs.android.com/search?q=file:androidx/leanback/widget/ParallaxEffect.java+class:androidx.leanback.widget.ParallaxEffect) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

*** ** * ** ***


```
public abstract class ParallaxEffect
```

<br />

*** ** * ** ***

ParallaxEffect class drives changes in `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget` in response to changes in variables defined in `https://developer.android.com/reference/androidx/leanback/widget/Parallax`.

ParallaxEffect has a list of `https://developer.android.com/reference/androidx/leanback/widget/Parallax.PropertyMarkerValue`s which represents the range of values that source variables can take. The main function is `https://developer.android.com/reference/androidx/leanback/widget/ParallaxEffect#performMapping(androidx.leanback.widget.Parallax)` which computes a fraction between 0 and 1 based on the current values of variables in `https://developer.android.com/reference/androidx/leanback/widget/Parallax`. As the parallax effect goes on, the fraction increases from 0 at beginning to 1 at the end. Then the fraction is passed on to `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget#update(float)`.

App use `https://developer.android.com/reference/androidx/leanback/widget/Parallax#addEffect(androidx.leanback.widget.Parallax.PropertyMarkerValue...)` to create a ParallaxEffect.

## Summary

| ### Public methods |
|---|---|
| `final void` | `https://developer.android.com/reference/androidx/leanback/widget/ParallaxEffect#addTarget(androidx.leanback.widget.ParallaxTarget)(https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget target)` Add a ParallaxTarget to run parallax effect. |
| `final https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/leanback/widget/Parallax.PropertyMarkerValue>` | `https://developer.android.com/reference/androidx/leanback/widget/ParallaxEffect#getPropertyRanges()()` Returns the list of `https://developer.android.com/reference/androidx/leanback/widget/Parallax.PropertyMarkerValue`s, which represents the range of values that source variables can take. |
| `final https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget>` | `https://developer.android.com/reference/androidx/leanback/widget/ParallaxEffect#getTargets()()` Returns the list of `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget` objects. |
| `final void` | `https://developer.android.com/reference/androidx/leanback/widget/ParallaxEffect#performMapping(androidx.leanback.widget.Parallax)(https://developer.android.com/reference/androidx/leanback/widget/Parallax source)` Perform mapping from `https://developer.android.com/reference/androidx/leanback/widget/Parallax` to list of `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget`. |
| `final void` | `https://developer.android.com/reference/androidx/leanback/widget/ParallaxEffect#removeTarget(androidx.leanback.widget.ParallaxTarget)(https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget target)` Remove a `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget` object from the list. |
| `final void` | `https://developer.android.com/reference/androidx/leanback/widget/ParallaxEffect#setPropertyRanges(androidx.leanback.widget.Parallax.PropertyMarkerValue...)(Parallax.PropertyMarkerValue[] markerValues)` Sets the list of `https://developer.android.com/reference/androidx/leanback/widget/Parallax.PropertyMarkerValue`s, which represents the range of values that source variables can take. |
| `final https://developer.android.com/reference/androidx/leanback/widget/ParallaxEffect` | `https://developer.android.com/reference/androidx/leanback/widget/ParallaxEffect#target(androidx.leanback.widget.ParallaxTarget)(https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget target)` Add a ParallaxTarget to run parallax effect. |
| `final https://developer.android.com/reference/androidx/leanback/widget/ParallaxEffect` | `https://developer.android.com/reference/androidx/leanback/widget/ParallaxEffect#target(java.lang.Object,android.animation.PropertyValuesHolder)(https://developer.android.com/reference/java/lang/Object.html targetObject, https://developer.android.com/reference/android/animation/PropertyValuesHolder.html values)` Creates a `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget` from `https://developer.android.com/reference/android/animation/PropertyValuesHolder.html` and adds it to the list of targets. |
| `final https://developer.android.com/reference/androidx/leanback/widget/ParallaxEffect` | `<T, V extends https://developer.android.com/reference/java/lang/Number.html> https://developer.android.com/reference/androidx/leanback/widget/ParallaxEffect#target(T,android.util.Property<T,V>)(T targetObject, https://developer.android.com/reference/android/util/Property.html<T, V> targetProperty)` Creates a `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget` using direct mapping from source property into target property, the new `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget` will be added to its list of targets. |

## Public methods

### addTarget

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
public final void addTarget(ParallaxTarget target)
```

Add a ParallaxTarget to run parallax effect.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget target` | ParallaxTarget to add. |

### getPropertyRanges

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
public final List<Parallax.PropertyMarkerValue> getPropertyRanges()
```

Returns the list of `https://developer.android.com/reference/androidx/leanback/widget/Parallax.PropertyMarkerValue`s, which represents the range of values that source variables can take.

| Returns |
|---|---|
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/leanback/widget/Parallax.PropertyMarkerValue>` | A list of `https://developer.android.com/reference/androidx/leanback/widget/Parallax.PropertyMarkerValue`s. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/leanback/widget/ParallaxEffect#performMapping(androidx.leanback.widget.Parallax)` |   |

### getTargets

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
public final List<ParallaxTarget> getTargets()
```

Returns the list of `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget` objects.

| Returns |
|---|---|
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget>` | The list of `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget` objects. |

### performMapping

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
public final void performMapping(Parallax source)
```

Perform mapping from `https://developer.android.com/reference/androidx/leanback/widget/Parallax` to list of `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget`.

### removeTarget

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
public final void removeTarget(ParallaxTarget target)
```

Remove a `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget` object from the list.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget target` | The `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget` object to be removed. |

### setPropertyRanges

```
public final void setPropertyRanges(Parallax.PropertyMarkerValue[] markerValues)
```

Sets the list of `https://developer.android.com/reference/androidx/leanback/widget/Parallax.PropertyMarkerValue`s, which represents the range of values that source variables can take.

| Parameters |
|---|---|
| `Parallax.PropertyMarkerValue[] markerValues` | A list of `https://developer.android.com/reference/androidx/leanback/widget/Parallax.PropertyMarkerValue`s. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/leanback/widget/ParallaxEffect#performMapping(androidx.leanback.widget.Parallax)` |   |

### target

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
public final ParallaxEffect target(ParallaxTarget target)
```

Add a ParallaxTarget to run parallax effect.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget target` | ParallaxTarget to add. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/leanback/widget/ParallaxEffect` | This ParallaxEffect object, allowing calls to methods in this class to be chained. |

### target

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
public final ParallaxEffect target(Object targetObject, PropertyValuesHolder values)
```

Creates a `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget` from `https://developer.android.com/reference/android/animation/PropertyValuesHolder.html` and adds it to the list of targets.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html targetObject` | Target object for PropertyValuesHolderTarget. |
| `https://developer.android.com/reference/android/animation/PropertyValuesHolder.html values` | PropertyValuesHolder for PropertyValuesHolderTarget. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/leanback/widget/ParallaxEffect` | This ParallaxEffect object, allowing calls to methods in this class to be chained. |

### target

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
public final ParallaxEffect <T, V extends Number> target(T targetObject, Property<T, V> targetProperty)
```

Creates a `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget` using direct mapping from source property into target property, the new `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget` will be added to its list of targets.

| Parameters |
|---|---|
| `<T>` | Type of target object. |
| `<V extends https://developer.android.com/reference/java/lang/Number.html>` | Type of target property value, either Integer or Float. |
| `T targetObject` | Target object for property. |
| `https://developer.android.com/reference/android/util/Property.html<T, V> targetProperty` | The target property that will receive values. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/leanback/widget/ParallaxEffect` | This ParallaxEffect object, allowing calls to methods in this class to be chained. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget#isDirectMapping()` |   |