Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does fillViewPort in scrollView really do?

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.

like image 297
Yousef Gamal Avatar asked Jun 13 '19 20:06

Yousef Gamal


People also ask

What is fillViewport in ScrollView?

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.

What is the use of NestedScrollView?

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.

How do I stop NestedScrollView scrolling?

setnestedscrollingenabled set it to false.

What is the difference between ListView and ScrollView?

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).


2 Answers

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

like image 113
ismail alaoui Avatar answered Sep 29 '22 01:09

ismail alaoui


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.

like image 33
Michael Plischke Avatar answered Sep 29 '22 01:09

Michael Plischke