Appbarlayout.scrollingviewbehavior - Bottom Of View Off Screen
When using an AppBarLayout with the standard ScrollingViewBehavior, the AppBarLayout's sibling will by default be the height of the CoordinatorLayout and the sibling's bottom will
Solution 1:
The solution I found to this issue involves 2 parts.
Add padding equal to the height of the
AppBarLayout
to the BOTTOM of theNestedScrollView
. In my case because the AppBarLayout only contained aToolbar
, the height was?attr/actionBarSize
.android:paddingBottom="?attr/actionBarSize"
Adding a custom
AppBarLayout.OnOffsetChangedListener
to theAppBarLayout
which changes the height of theNestedScrollView
as the toolbar is collapsed.classScrollingOffsetFixListener( privateval nestedScrollView: NestedScrollView ): AppBarLayout.OnOffsetChangedListener { privatevar originalHeight = 0privatevar firstOffset = trueoverridefunonOffsetChanged(layout: AppBarLayout?, offset: Int) { if(firstOffset) { firstOffset = false originalHeight = nestedScrollView.measuredHeight } val params = nestedScrollView.layoutParams params.height = originalHeight + (offset * -1) nestedScrollView.layoutParams = params } }
Post a Comment for "Appbarlayout.scrollingviewbehavior - Bottom Of View Off Screen"