Skip to content
Advertisement

CoordinatorLayout with NestedScrollView adding padding bottom for sticky button not working

I have this scenario :

I’ve created this

JavaScript

Then here’s my layout

JavaScript

Then I’m doing the collapsing animation as :

JavaScript

It works flawless, the problem is now that I want to add a sticky button but I can not tell to NestedScrollView to be aligned bottomToTopOf my button because it’s not inside a ConstraintLayout neither it’s a child of it, so it doesn’t crash in terms of compiling but the button hides the last part of the scrollView… I’ve tried to add marginBottom="buttonSize" and in the layout design it looks good, but when compiling it doesn’t do the collapsing animation because I’ve added the marginBottom. How can I fix this? I need this NestedScrollView to be not height match_parent even if it’s wrap_content it’s aligned to the parent and the button is overlapped.

Advertisement

Answer

You can wrap the CoordinatorLayout & the bottom Button inside a ConstraintLayout as the root layout; now the CoordinatorLayout can be constraint to the top of the button instead of having a height that equals to the entire screen height.

So, the layout would be:

JavaScript

Applying to your layout:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement