# ParallaxEffect

# 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)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/leanback/widget/ParallaxEffect "View this page in Java")

<br />

```
abstract class ParallaxEffect
```

<br />

*** ** * ** ***

ParallaxEffect class drives changes in[ParallaxTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget)in response to changes in variables defined in[Parallax](https://developer.android.com/reference/kotlin/androidx/leanback/widget/Parallax).

ParallaxEffect has a list of[Parallax.PropertyMarkerValue](https://developer.android.com/reference/kotlin/androidx/leanback/widget/Parallax.PropertyMarkerValue)s which represents the range of values that source variables can take. The main function is[performMapping](https://developer.android.com/reference/kotlin/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[Parallax](https://developer.android.com/reference/kotlin/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[update](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget#update(float)).

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

## Summary

|                                                                                                                                                              ### Public functions                                                                                                                                                               |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                                                                                                                                                                                                   | [addTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxEffect#addTarget(androidx.leanback.widget.ParallaxTarget))`(target: `[ParallaxTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget)`!)` Add a ParallaxTarget to run parallax effect.                                                                                                                                                                                                                                                                                                                                                                                 |
| `(`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)`)`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[Parallax.PropertyMarkerValue](https://developer.android.com/reference/kotlin/androidx/leanback/widget/Parallax.PropertyMarkerValue)`!>!` | [getPropertyRanges](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxEffect#getPropertyRanges())`()` Returns the list of[PropertyMarkerValue](https://developer.android.com/reference/kotlin/androidx/leanback/widget/Parallax.PropertyMarkerValue)s, which represents the range of values that source variables can take.                                                                                                                                                                                                                                                                                                                                                  |
| `(`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)`)`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[ParallaxTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget)`!>!`                             | [getTargets](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxEffect#getTargets())`()` Returns the list of[ParallaxTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget)objects.                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                                                                                                                                                                                                   | [performMapping](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxEffect#performMapping(androidx.leanback.widget.Parallax))`(source: `[Parallax](https://developer.android.com/reference/kotlin/androidx/leanback/widget/Parallax)`!)` Perform mapping from[Parallax](https://developer.android.com/reference/kotlin/androidx/leanback/widget/Parallax)to list of[ParallaxTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget).                                                                                                                                                                                                  |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                                                                                                                                                                                                   | [removeTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxEffect#removeTarget(androidx.leanback.widget.ParallaxTarget))`(target: `[ParallaxTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget)`!)` Remove a[ParallaxTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget)object from the list.                                                                                                                                                                                                                                                                                  |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                                                                                                                                                                                                   | [setPropertyRanges](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxEffect#setPropertyRanges(androidx.leanback.widget.Parallax.PropertyMarkerValue...))`(markerValues: `[Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[Parallax.PropertyMarkerValue](https://developer.android.com/reference/kotlin/androidx/leanback/widget/Parallax.PropertyMarkerValue)`!>!)` Sets the list of[PropertyMarkerValue](https://developer.android.com/reference/kotlin/androidx/leanback/widget/Parallax.PropertyMarkerValue)s, which represents the range of values that source variables can take.                                                    |
| [ParallaxEffect](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxEffect)`!`                                                                                                                                                                                                                                     | [target](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxEffect#target(androidx.leanback.widget.ParallaxTarget))`(target: `[ParallaxTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget)`!)` Add a ParallaxTarget to run parallax effect.                                                                                                                                                                                                                                                                                                                                                                                       |
| [ParallaxEffect](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxEffect)`!`                                                                                                                                                                                                                                     | [target](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxEffect#target(java.lang.Object,android.animation.PropertyValuesHolder))`(targetObject: `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`!, values: `[PropertyValuesHolder](https://developer.android.com/reference/android/animation/PropertyValuesHolder.html)`!)` Creates a[ParallaxTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget)from[PropertyValuesHolder](https://developer.android.com/reference/android/animation/PropertyValuesHolder.html)and adds it to the list of targets.                                               |
| [ParallaxEffect](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxEffect)`!`                                                                                                                                                                                                                                     | `<T, V : `[Number](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-number/index.html)`?> `[target](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxEffect#target(T,android.util.Property<T,V>))`(targetObject: T!, targetProperty: `[Property](https://developer.android.com/reference/android/util/Property.html)`<T!, V!>!)` Creates a[ParallaxTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget)using direct mapping from source property into target property, the new[ParallaxTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget)will be added to its list of targets. |

## Public functions

### addTarget

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

```
fun addTarget(target: ParallaxTarget!): Unit
```

Add a ParallaxTarget to run parallax effect.  

|                                                      Parameters                                                       |
|-----------------------------------------------------------------------------------------------------------------------|------------------------|
| `target: `[ParallaxTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget)`!` | ParallaxTarget to add. |

### getPropertyRanges

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

```
fun getPropertyRanges(): (Mutable)List<Parallax.PropertyMarkerValue!>!
```

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

|                                                                                                                                                                     Returns                                                                                                                                                                     |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|
| `(`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)`)`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[Parallax.PropertyMarkerValue](https://developer.android.com/reference/kotlin/androidx/leanback/widget/Parallax.PropertyMarkerValue)`!>!` | A list of[Parallax.PropertyMarkerValue](https://developer.android.com/reference/kotlin/androidx/leanback/widget/Parallax.PropertyMarkerValue)s. |

|                                                                          See also                                                                          |
|------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [performMapping](https://developer.android.com/reference/kotlin/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)  

```
fun getTargets(): (Mutable)List<ParallaxTarget!>!
```

Returns the list of[ParallaxTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget)objects.  

|                                                                                                                                                       Returns                                                                                                                                                       |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|
| `(`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)`)`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[ParallaxTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget)`!>!` | The list of[ParallaxTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget)objects. |

### performMapping

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

```
fun performMapping(source: Parallax!): Unit
```

Perform mapping from[Parallax](https://developer.android.com/reference/kotlin/androidx/leanback/widget/Parallax)to list of[ParallaxTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget).  

### removeTarget

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

```
fun removeTarget(target: ParallaxTarget!): Unit
```

Remove a[ParallaxTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget)object from the list.  

|                                                      Parameters                                                       |
|-----------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------|
| `target: `[ParallaxTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget)`!` | The[ParallaxTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget)object to be removed. |

### setPropertyRanges

```
fun setPropertyRanges(markerValues: Array<Parallax.PropertyMarkerValue!>!): Unit
```

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

|                                                                                                                 Parameters                                                                                                                  |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|
| `markerValues: `[Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[Parallax.PropertyMarkerValue](https://developer.android.com/reference/kotlin/androidx/leanback/widget/Parallax.PropertyMarkerValue)`!>!` | A list of[PropertyMarkerValue](https://developer.android.com/reference/kotlin/androidx/leanback/widget/Parallax.PropertyMarkerValue)s. |

|                                                                          See also                                                                          |
|------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [performMapping](https://developer.android.com/reference/kotlin/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)  

```
fun target(target: ParallaxTarget!): ParallaxEffect!
```

Add a ParallaxTarget to run parallax effect.  

|                                                      Parameters                                                       |
|-----------------------------------------------------------------------------------------------------------------------|------------------------|
| `target: `[ParallaxTarget](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ParallaxTarget)`!` | ParallaxTarget to add. |

|                                                   Returns                                                   |
|-------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|
| [ParallaxEffect](https://developer.android.com/reference/kotlin/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)  

```
fun target(targetObject: Any!, values: PropertyValuesHolder!): ParallaxEffect!
```

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

|                                                        Parameters                                                        |
|--------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------|
| `targetObject: `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`!`                           | Target object for PropertyValuesHolderTarget.        |
| `values: `[PropertyValuesHolder](https://developer.android.com/reference/android/animation/PropertyValuesHolder.html)`!` | PropertyValuesHolder for PropertyValuesHolderTarget. |

|                                                   Returns                                                   |
|-------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|
| [ParallaxEffect](https://developer.android.com/reference/kotlin/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)  

```
fun <T, V : Number?> target(targetObject: T!, targetProperty: Property<T!, V!>!): ParallaxEffect!
```

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

|                                                 Parameters                                                  |
|-------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|
| `<T>`                                                                                                       | Type of target object.                                  |
| `<V : `[Number](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-number/index.html)`?>`                | Type of target property value, either Integer or Float. |
| `targetObject: T!`                                                                                          | Target object for property.                             |
| `targetProperty: `[Property](https://developer.android.com/reference/android/util/Property.html)`<T!, V!>!` | The target property that will receive values.           |

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

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