InterpolateOnScrollPositionChangeHelper

public class InterpolateOnScrollPositionChangeHelper
extends Object

java.lang.Object
   ↳ com.google.android.material.shape.InterpolateOnScrollPositionChangeHelper


Helper class to handle shape interpolation when shaped views enter or exit the window.

Summary

Public constructors

InterpolateOnScrollPositionChangeHelper(View shapedView, MaterialShapeDrawable materialShapeDrawable, ScrollView containingScrollView)

Instantiate a scroll position helper.

Public methods

void setContainingScrollView(ScrollView containingScrollView)

Set the ScrollView which contains the View being interpolated.

void setMaterialShapeDrawable(MaterialShapeDrawable materialShapeDrawable)

Set the MaterialShapeDrawable which will be interpolated.

void startListeningForScrollChanges(ViewTreeObserver viewTreeObserver)

Start listening for scroll changes and interpolating based on position.

void stopListeningForScrollChanges(ViewTreeObserver viewTreeObserver)

Stop listening for scroll changes and interpolating based on position.

void updateInterpolationForScreenPosition()

Updates the MaterialShapeDrawable's interpolation based on the View's position in the containing ScrollView.

Inherited methods

Public constructors

InterpolateOnScrollPositionChangeHelper

public InterpolateOnScrollPositionChangeHelper (View shapedView, 
                MaterialShapeDrawable materialShapeDrawable, 
                ScrollView containingScrollView)

Instantiate a scroll position helper.

Parameters
shapedView View: the View whose background is a MaterialShapeDrawable and which is scrolled in and out of view.

materialShapeDrawable MaterialShapeDrawable: the MaterialShapeDrawable which will be interpolated.

containingScrollView ScrollView: the ScrollView that contains shapedView.

Public methods

setContainingScrollView

public void setContainingScrollView (ScrollView containingScrollView)

Set the ScrollView which contains the View being interpolated.

setMaterialShapeDrawable

public void setMaterialShapeDrawable (MaterialShapeDrawable materialShapeDrawable)

Set the MaterialShapeDrawable which will be interpolated.

Parameters
materialShapeDrawable MaterialShapeDrawable: the desired drawable.

startListeningForScrollChanges

public void startListeningForScrollChanges (ViewTreeObserver viewTreeObserver)

Start listening for scroll changes and interpolating based on position.

Parameters
viewTreeObserver ViewTreeObserver: {@link ViewTreeObserver belonging to the {@link View} being interpolated.

stopListeningForScrollChanges

public void stopListeningForScrollChanges (ViewTreeObserver viewTreeObserver)

Stop listening for scroll changes and interpolating based on position.

Parameters
viewTreeObserver ViewTreeObserver: {@link ViewTreeObserver belonging to the {@link View} being interpolated.

updateInterpolationForScreenPosition

public void updateInterpolationForScreenPosition ()

Updates the MaterialShapeDrawable's interpolation based on the View's position in the containing ScrollView.