Pull to collapse

Saket Narayan edited this page Sep 16, 2018 · 8 revisions

Intercept gesture

ExpandablePageLayout currently does not understand nested scrolling, so if the content contains scrollable child Views, the pull-to-collapse gesture will have to be intercepted manually.

expandablePage.pullToCollapseInterceptor = { downX, downY, upwardPull ->
  val directionInt = if (upwardPull) +1 else -1
  val canScrollFurther = scrollableContainer.canScrollVertically(directionInt)
  if (canScrollFurther) InterceptResult.INTERCEPTED else InterceptResult.IGNORED
}

When the scrollable children do not consume the entire space, the downX and downY parameters can be used to check if the touch actually lies on them. See the sample app for an example.

Collapse threshold

When the content is pulled and released, ExpandablePageLayout uses the default toolbar height as the threshold to decide if the content can be collapsed. This can be customised using,

expandablePage.pullToCollapseThresholdDistance = THRESHOLD_IN_PIXELS
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.