How to get ScrollView height (getHeight() = 0) and how to display an arrow that it is scrollable?

Lets say that we have a ScrollView which should ahave an arrow at its bottom. That arrow is visible only when the ScrollView is scrollable (That means it has more content than it can display).

In android the scrollview does not have a method isScrollable() and I am still wondering what is the reason. May be too complex realization.

I spent more than 8 hours on this so the answer is:
Attach a ViewTreeObserver. This will fire up when the scrollview is added to the android display and you can call the getHeight() which will return your scrollview’s height. If you try to do it in onViewCreated or somewhere else it will be 0 (personal experience).


 ViewTreeObserver vto = mScrollView.getViewTreeObserver();

 vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {


     public void onGlobalLayout() {

         ViewTreeObserver obs = mScrollView.getViewTreeObserver();



         } else {



         int totalHeight =

             getResources().getDimensionPixelSize(R.dimen.article_details_item_img_height) +

                 mArticleText.getHeight() + getResources().getDimensionPixelSize(


         if (totalHeight <= mScrollView.getHeight()) {





You may also like...