Search code examples
androidscrollview

Get height of ScrollView hidden part


Imagine a situation when screen is at middle of ScrollView. Is it possible to get height in pixels of hidden part at top?

enter image description here

It is possible to get height of visible screen part:

 Rect scrollBounds = new Rect();
 mScrollView.getHitRect(scrollBounds);

Possible to get height of ScrollView by getting it's child height:

 int mScrollViewHeight = mScrollView.getHeight();

But how do I determine height of that hidden part?


Solution

  • mScrollView.getScrollY(); returns the scrolled top position of this view which is the height of the "hidden" part at the top.