how to implement Scroller in textview for auto scrolling?

前端 未结 2 1466
萌比男神i
萌比男神i 2021-01-03 11:31

I have used scroller for auto scrolling, but it keeps on scrolling even when text gets over. I want to find the position and want to stop scrolling automatically, so thta te

2条回答
  •  悲&欢浪女
    2021-01-03 11:38

    Nikki

    You need to check the source code here .

    again text must comes to its initial position

    for this use scrollTo(0, 0);

    i want to find the position

    use scroll.getCurrX();

    want to stop scrolling automatically

    use scroll.abortAnimation();

    & you are done!:)

    EDITED:

    Nikki,I wrote a class derived from Android.Widget.TextView to customize a TextView in which text can be scrolled until text is finished & after finishing text comes back to initial position.All you need to do is create custom class as defined here & just override computeScroll () as below

    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 
    }
    }
    

提交回复
热议问题