InterpolateOnScrollPositionChangeHelper

public class 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

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

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

Public constructors

InterpolateOnScrollPositionChangeHelper

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

Instantiate a scroll position helper.

Parameters
View shapedView

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

MaterialShapeDrawable materialShapeDrawable

the MaterialShapeDrawable which will be interpolated.

ScrollView containingScrollView

the ScrollView that contains shapedView.

Public methods

setContainingScrollView

public void setContainingScrollView(ScrollView containingScrollView)

Set the ScrollView which contains the View being interpolated.

Parameters
ScrollView containingScrollView

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

belonging to the { } being interpolated.

stopListeningForScrollChanges

public void stopListeningForScrollChanges(ViewTreeObserver viewTreeObserver)

Stop listening for scroll changes and interpolating based on position.

Parameters
ViewTreeObserver viewTreeObserver

belonging to the { } being interpolated.

updateInterpolationForScreenPosition

public void updateInterpolationForScreenPosition()

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