Reputation: 1288
I have a TextView
inside a ScrollView
. I have used the below code to scroll programmatically.
mScrollView.post(new Runnable() {
public void run() {
mScrollView.scrollTo(0, mScrollView.getBottom());
}
});
It does fine. Now But I want to control the scrolling speed of scrollview in differend speed values. How to get it?
Upvotes: 3
Views: 5363
Reputation: 1288
After few searches, this is what worked for me. Here is the code I used to slow down the scroll speed of ScrollView programmatically,
ObjectAnimator anim = ObjectAnimator.ofInt(mScrollView, "scrollY", mScrollView.getBottom());
anim.setDuration(9000);
anim.start();
mScrollView - Your ScrollView
mScrollView = (ScrollView) findViewById(R.id.scrollView1);
anima.setDuration(int Value)
- greater the value, slower the scroll I used the code block in Switch
Button OnCheckedChangedListener
.
Upvotes: 2
Reputation: 15336
Or you can animation for smooth scrolling
ObjectAnimator animator=ObjectAnimator.ofInt(yourScrollView, "scrollY",targetYScroll );
animator.start();
Upvotes: 3