1

I am trying to figure out how to have CoordinatorLayout scrolling range to be not screen height. My layout structure is following:

CoordinatorLayout

-- AppBarLayout

---- CollapsingToolbarLayout (scrollflags: scroll)

------ Toolbar (CollapseMode: parallax)

----- /CollapsingToolbarLayout

-- /AppBarLayout

-- NestedScrollView (Behaviour: appbar_scrolling_view_behavior)

-- /NestedScrollView

/ CoordinatorLayout

Even when NestedScrollView child height is like 100dp it can be scrolled all the way top when the content should not be scrollable at all.

Is there a way to affect the scroll range of CoordinatorLayout that if the child content is scrollable it will scroll and only the range that the height is.

I am also seeing this issue when child is RecyclerView and it has e.g. 1 50dp height child -> it should not scroll at all in this case, but when child count gets bigger it should then scroll.

Thanks.

Community
  • 1
  • 1
Niko
  • 8,093
  • 5
  • 49
  • 85

2 Answers2

1

Using AppBarLayout.ScrollingViewBehavior from below link fixes the issue with NestedScrollView

https://github.com/natario1/ConstrainedScrollBehavior/blob/master/ConstrainedScrollBehavior.java

Niko
  • 8,093
  • 5
  • 49
  • 85
  • I don't have `CollapsingToolbarLayout` (just some `LinearLayout` inside 'AppBarLayout' that needs to be scrolled when `RecyclerView` is scrolled), but encountered the issue as well. This solution helped indeed. Thanks a lot. – Alex Semeniuk Jul 07 '22 at 14:04
0

I think as long as there's a scroll behavior in the layout and collapsingtoolbar has a scroll flag, it always can be scroll.

but you can try this trick to disable the scroll

How to disable CollapsingToolbar's collapse when scroll has not content?