samedi 9 janvier 2016

How to get exact events of scrolled to top and bottom in scrollview

Vote count: 0

I tried many ways explained around here on stackoverflow.But i am still not able to perfectly get each of the events in scrollview.

What i intend to do is change text in an edittext (wrapped inside scrollview) when top or bottom is reached so that large files can be loaded.

        public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
            View view = (View) scrollView.getChildAt(scrollView.getChildCount() - 1);
            int diff = (view.getBottom() - (scrollView.getHeight() + scrollView.getScrollY()));

            // if diff is zero, then the bottom has been reached
            if (diff == 0) {
                if(index<texts.size()-1){
                    scrollView.scrollTo(0,0);
                    index++;
                    mInput.setText(texts.get(index));
                }
            }
                // do stuff similarly for top position reached
        }

asked 1 min ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



How to get exact events of scrolled to top and bottom in scrollview

Aucun commentaire:

Enregistrer un commentaire