0

In my app I have a scroll view with n number of data to be listed out. There are two buttons one is named as UP placed above scroll view and the other is DOWN placed below scroll view. Using the UP and DOWN buttons the list of views can be scrolled.

When the scroll bar is in top the Up button will be invisible and when the scroll bar reaches the bottom the DOWN button will become invisible, I have written logic for this using the getScrollX() method.

Now my problem is when there is very few data for example 3, the scroll bar will not be visible and the layout cannot be scrolled, in such a case both the UP and DOWN buttons need to be in invisible. How to do this, please suggest me a way?

Siva K
  • 4,968
  • 14
  • 82
  • 161

1 Answers1

0

You can try and use a ViewTreeObserver to check the dimension of the View inside your ScrollView. If the dimension exceeds a certain limit (such as the screen size), the ScrollView will be scrollable. See this preview SO answer for more details. Hope that helps!

Community
  • 1
  • 1
AggelosK
  • 4,313
  • 2
  • 32
  • 37