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 text comes to its initial position as during text scrolling text gets over. How can i do this?
The code used for autoscrolling is:
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);
}
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
}
}
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.