What is the benefit of fillViewPort?
In ScrollView, sometimes fillViewPort needs to be set to true so that the view gets displayed probably, and other times it's not needed at all.
And the documentations' description of it is not really clear
android:fillViewport
Defines whether the scrollview should stretch its content to fill the viewport.
fillViewport allows scrollView to extend it's height equals to the full height of device screen's height in the cases when the child of scroll view has less height.
NestedScrollView is just like ScrollView , but it supports acting as both a nested scrolling parent and child on both new and old versions of Android. Nested scrolling is enabled by default.
setnestedscrollingenabled set it to false.
They're completely different. A ScrollView is simple a scrolling container you can use to scroll whatever you put inside it, which might be a list of items, or it might not. A ListView is very specifically designed to hold lists, where items typically look the same (or at least follow a pattern, e.g. section headings).
fillViewport allows scrollView to extend it’s height equals to the full height of device screen’s height in the cases when the child of scroll view has less height.
Thank for Hardik Parsania for this helpful post
fillViewport = true is advised for scrollViews containing a recyclerView that implements padding in the direction of the scroll (i.e. paddingBottom and/or paddingTop for vertical scrolling). Doing so, when paired with clipToPadding = false for the recyclerView, negates shrinkage of the viewport on scrolling to the point at which the recyclerView padding enters view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With