Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check whether ScrollView is scrollable

Tags:

android

I was wondering, how to check whether the current ScrollView is scrollable? It seems that, there isn't public method called canScroll or isScrollable in ScrollView.

Scrollable : You can move the ViewGroup inside the ScrollView up and down, and the scroll bar will be visible when you move it up and down. So, if there is only little rows in the ScrollView, and they can fit inside single screen, ScrollView is not scrollable then.

like image 441
Cheok Yan Cheng Avatar asked Oct 21 '13 19:10

Cheok Yan Cheng


1 Answers

scrollView.viewTreeObserver
        .addOnGlobalLayoutListener {

            val isScrollable = scrollView.canScrollVertically(1)
        }
like image 177
coder Avatar answered Sep 23 '22 12:09

coder