how to implement Scroller in textview for auto scrolling?

前端 未结 2 1467
萌比男神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 
    }
    }
    
    0 讨论(0)
  • 2021-01-03 11:46

    Your question inspired me to blog about this as I had similar problem just some days ago: http://b.ivity.asia/2010/12/01/extended-marquee-in-android/

    I wanted to use a very custom Marquee effect, this class should be able to do the job for you.

    0 讨论(0)
提交回复
热议问题