1

I have a textview which only shows 3 lines and then you have to scroll to the other ones. I set the textview in my xml file as scrollable and activated its scrolling method with textview.setMovementMethod(new ScrollingMovementMethod()). The scrolling works perfectly fine.

The problem I face is, that I need to know when the user has scrolled to the bottom of the textview in the case that the textview has more than 3 lins. Is there a way to check when the user has scrolled to bottom of the textview?

I played a little bit around with the OnTouchListener, OnDragListener and OnHoverListener but none of them really worked.

If you need more details, just let me know. Thanks for your help!

Christian X
  • 1,000
  • 7
  • 14

1 Answers1

0

You can try this :

 scrollView.getViewTreeObserver()
       .addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
            @Override
            public void onScrollChanged() {
                if (scrollView.getChildAt(0).getBottom()
                     <= (scrollView.getHeight() + scrollView.getScrollY())) {
                    //scroll view is at bottom
                } else {
                    //scroll view is not at bottom
                }
            }
        });

Best

Maxouille
  • 2,200
  • 2
  • 15
  • 38
  • I checked the linked post but can't understand how this could provide the solution for my question. The posted link is about nested scrollviews and mine is only about textviews which can be scrolled. Could you maybe explain a little bit more what you mean with your answer? – Christian X Mar 04 '19 at 14:10