# ParallaxTarget

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

*** ** * ** ***


```
public abstract class ParallaxTarget
```

<br />

Known direct subclasses [ParallaxTarget.DirectPropertyTarget](https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget.DirectPropertyTarget), [ParallaxTarget.PropertyValuesHolderTarget](https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget.PropertyValuesHolderTarget)

|---|---|
| `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget.DirectPropertyTarget` | DirectPropertyTarget is to support direct mapping into either Integer Property or Float Property. |
| `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget.PropertyValuesHolderTarget` | PropertyValuesHolderTarget is an implementation of `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget` that uses `https://developer.android.com/reference/android/animation/PropertyValuesHolder.html` to update the target object. |

*** ** * ** ***

ParallaxTarget is responsible for updating the target through the `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget#update(float)` method or the `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget#directUpdate(java.lang.Number)` method when `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget#isDirectMapping()` is true. When `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget#isDirectMapping()` is false, `https://developer.android.com/reference/androidx/leanback/widget/ParallaxEffect` transforms the values of `https://developer.android.com/reference/androidx/leanback/widget/Parallax`, which represents the current state of UI, into a float value between 0 and 1. That float value is passed into `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget#update(float)` method.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget.DirectPropertyTarget<T, V extends https://developer.android.com/reference/java/lang/Number.html> extends https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget` DirectPropertyTarget is to support direct mapping into either Integer Property or Float Property. |
| `public final class https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget.PropertyValuesHolderTarget extends https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget` PropertyValuesHolderTarget is an implementation of `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget` that uses `https://developer.android.com/reference/android/animation/PropertyValuesHolder.html` to update the target object. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget#ParallaxTarget()()` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget#directUpdate(java.lang.Number)(https://developer.android.com/reference/java/lang/Number.html value)` Directly update the target using a float or int value. |
| `boolean` | `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget#isDirectMapping()()` Returns true if the ParallaxTarget is directly mapping from source value, `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget#directUpdate(java.lang.Number)` will be used to update value, otherwise update(fraction) will be called to update value. |
| `void` | `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget#update(float)(float fraction)` Implementation class is supposed to update target with the provided fraction (between 0 and 1). |

## Public constructors

### ParallaxTarget

Added in 1.1.0

```
public ParallaxTarget()
```

## Public methods

### directUpdate

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

```
public void directUpdate(Number value)
```

Directly update the target using a float or int value. Called when `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget#isDirectMapping()` is true.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/Number.html value` | Either int or float value. |

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

### isDirectMapping

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

```
public boolean isDirectMapping()
```

Returns true if the ParallaxTarget is directly mapping from source value, `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget#directUpdate(java.lang.Number)` will be used to update value, otherwise update(fraction) will be called to update value. Default implementation returns false.

| Returns |
|---|---|
| `boolean` | True if direct mapping, false otherwise. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget#directUpdate(java.lang.Number)` |   |
| `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget#update(float)` |   |

### update

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

```
public void update(float fraction)
```

Implementation class is supposed to update target with the provided fraction (between 0 and 1). The fraction represents percentage of completed change (e.g. scroll) on target. Called only when `https://developer.android.com/reference/androidx/leanback/widget/ParallaxTarget#isDirectMapping()` is false.

| Parameters |
|---|---|
| `float fraction` | Fraction between 0 to 1. |

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