6

When i scrollTo(0,250) i want to include an animation with the scrollaction. i did this code but it is not scrolling according to the animation. scrollMe is the scrolling widget id.

ObjectAnimator anim = ObjectAnimator.ofInt(scrollMe, "translationY",
                        250, 0);
                anim.setDuration(800);
                anim.start();
                scrollMe.scrollTo(0, 250);
Bhoomika Brahmbhatt
  • 7,032
  • 3
  • 25
  • 43
Dimitri
  • 1,864
  • 7
  • 38
  • 64

1 Answers1

10
ObjectAnimator objectAnimator = ObjectAnimator.ofInt(view, "scrollY", 0, 250).setDuration(duration);
objectAnimator.start();
venciallee
  • 715
  • 4
  • 19
  • should i use scrollMe.scrollTo(0, scrollMe.getBottom()); too ? if so before or after objectAnimator ? – Dimitri Jan 06 '14 at 06:27
  • no, "scrollY" animator already had scrolled at the position whatever you want with duration.also,if so it may influence the animator,you can try it. – venciallee Jan 06 '14 at 06:38
  • I tried to use your approach. It's animate `ScrollView` but there is small issue during this animation, part of `ScrollView` that became visible on the screen is gray and content of this part not drawn. Do you know what can cause this effect? – Volodymyr Apr 08 '15 at 14:56
  • the perfect answer – Fattie Apr 09 '21 at 22:50