How to implement a scroller in text mode for automatic scrolling?

I used the scroller to automatically scroll, but it continues to scroll even when the text ends. I want to find a position and I want to automatically stop scrolling, so the thta text goes back to its original position, since the text of the scroll text ends. How can i do this?

Auto scroll code:

public void Scroll()
{
    //text = (TextView) findViewById(R.id.TxtView);
    length = text.getLineCount();
    scroll.computeScrollOffset();
    text.setScroller(scroll);
    int a = text.getBottom();
    int b = text.getTop();
    //scroll.extendDuration(scroll.getFinalY());
    scroll.startScroll(scroll_x, scroll_y, 0, a, (500000)/ speedAmount);    
}
+3
source share
2 answers

Nikki

You need to check the source code here .

again the text should come to its original position

for this use scrollTo(0, 0);

I want to find a position

use scroll.getCurrX();

want to stop scrolling automatically

use scroll.abortAnimation();

& you are done! :)

Edition:

Nikki, , Android.Widget.TextView, TextView, , . , , computeScroll (),

public void computeScroll() {
super.computeScroll();

if (null == mSlr) return;

if (mSlr.isFinished() && (!mPaused)) {
scrollTo(0, 0);//scroll to initial position or whatever position you want it to scroll 
}
}
+1

Source: https://habr.com/ru/post/1777063/


All Articles