I want do a animate scroll like Jquery´s (in this web page works when you click in top menu´s options) in android. is it possible? I have seen that exists scrollTo but is possible to do with animation and not like jumps. Thank you very much.
Asked
Active
Viewed 279 times
0
-
are you using ListView ? – Tejas Jun 17 '14 at 10:31
-
no, I am not using ListView. I use scrollview with layouts – user3733523 Jun 17 '14 at 10:33
-
Duplicate of this: http://stackoverflow.com/questions/10621439/how-to-animate-scroll-position-how-to-scroll-smoothly – Eran Goldin Jun 17 '14 at 10:33
-
Is there a good tutorial or example of smoothScrollTo for android? – user3733523 Jun 17 '14 at 10:55
1 Answers
0
Using ObjectAnimator, This is a sample for scrolling to top :
public void scroolToTop() {
int x = 0;
int y = 0;
ObjectAnimator xTranslate = ObjectAnimator.ofInt(mScrollView, "scrollX", x);
ObjectAnimator yTranslate = ObjectAnimator.ofInt(mScrollView, "scrollY", y);
AnimatorSet animators = new AnimatorSet();
animators.setDuration(1000L);
animators.playTogether(xTranslate, yTranslate);
animators.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator arg0) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animator arg0) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animator arg0) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationCancel(Animator arg0) {
// TODO Auto-generated method stub
}
});
animators.start();
}

anton46
- 391
- 3
- 3