public
abstract
class
Parallax
extends Object
| java.lang.Object | |
| ↳ | android.support.v17.leanback.widget.Parallax<PropertyT extends android.util.Property> |
|
|
|
|
Parallax tracks a list of dynamic Propertys typically representing foreground UI
element positions on screen. Parallax keeps a list of ParallaxEffect objects which define
rules to mapping property values to ParallaxTarget.
To create a ParallaxEffect, user calls addEffect(PropertyMarkerValue[]) with a
list of Parallax.PropertyMarkerValue which defines the range of Parallax.IntProperty or
Parallax.FloatProperty. Then user adds ParallaxTarget into
ParallaxEffect.
App may subclass Parallax.IntProperty or Parallax.FloatProperty to supply
additional information about how to retrieve Property value. RecyclerViewParallax is
a great example of Parallax implementation tracking child view positions on screen.
Subclass must override updateValues() to update property values and perform
ParallaxEffects. Subclass may call updateValues() automatically e.g.
RecyclerViewParallax calls updateValues() in RecyclerView scrolling. App might
call updateValues() manually when Parallax is unaware of the value change. For example,
when a slide transition is running, RecyclerViewParallax is unaware of translation value
changes; it's the app's responsibility to call updateValues() in every frame of
animation.
classParallax.FloatProperty
FloatProperty provide access to an index based integer type property inside
Parallax.
classParallax.IntProperty
IntProperty provide access to an index based integer type property inside
Parallax.
classParallax.PropertyMarkerValue<PropertyT>
Class holding a fixed value for a Property in Parallax.
Public constructors | |
|---|---|
Parallax()
|
|
Public methods | |
|---|---|
ParallaxEffect
|
addEffect(PropertyMarkerValue... ranges)
Create a |
final
PropertyT
|
addProperty(String name)
Add a new IntProperty in the Parallax object. |
abstract
PropertyT
|
createProperty(String name, int index)
Create a new Property object. |
List<ParallaxEffect>
|
getEffects()
Returns a list of |
abstract
float
|
getMaxValue()
Return the max value which is typically size of parent visible area, e.g. |
final
List<PropertyT>
|
getProperties()
|
void
|
removeAllEffects()
Remove all |
void
|
removeEffect(ParallaxEffect effect)
Remove the |
void
|
updateValues()
Update property values and perform |
Inherited methods | |
|---|---|
java.lang.Object
| |
ParallaxEffect addEffect (PropertyMarkerValue... ranges)
Create a ParallaxEffect object that will track source variable changes within a
provided set of ranges.
| Parameters | |
|---|---|
ranges |
PropertyMarkerValue: A list of marker values that defines the ranges. |
| Returns | |
|---|---|
ParallaxEffect |
Newly created ParallaxEffect object. |
PropertyT addProperty (String name)
Add a new IntProperty in the Parallax object. App may override
createProperty(String, int).
| Parameters | |
|---|---|
name |
String: Name of the property. |
| Returns | |
|---|---|
PropertyT |
Newly created Property object. |
See also:
PropertyT createProperty (String name,
int index)Create a new Property object. App does not directly call this method. See
addProperty(String).
| Parameters | |
|---|---|
name |
String |
index |
int: Index of the property in this Parallax object. |
| Returns | |
|---|---|
PropertyT |
Newly created Property object. |
List<ParallaxEffect> getEffects ()
Returns a list of ParallaxEffect object which defines rules to perform mapping to
multiple ParallaxTargets.
| Returns | |
|---|---|
List<ParallaxEffect> |
A list of ParallaxEffect object.
|
float getMaxValue ()
Return the max value which is typically size of parent visible area, e.g. RecyclerView's height if we are tracking Y position of a child. The size can be used to calculate marker value using the provided fraction of FloatPropertyMarkerValue.
| Returns | |
|---|---|
float |
Size of parent visible area. |
List<PropertyT> getProperties ()
| Returns | |
|---|---|
List<PropertyT> |
A unmodifiable list of properties. |
void removeAllEffects ()
Remove all ParallaxEffect objects.
void removeEffect (ParallaxEffect effect)
Remove the ParallaxEffect object.
| Parameters | |
|---|---|
effect |
ParallaxEffect: The ParallaxEffect object to remove.
|
void updateValues ()
Update property values and perform ParallaxEffects. Subclass may override and call
super.updateValues() after updated properties values.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.