How to use animation for animation

I am new to android. I am trying to animate a horizontal arrow, but could not do it. I just want an animation in which the search drum shows a move for some duration, say, 1 min. Can someone suggest / give ideas / code snippet on how I should animate the standard search bar?

What kind of animation can be used as an objectanimator or valueAnimation? Do I need to define a trigger method (not sure!) For thumb animation to move to the next position?

Thanks in advance.

+6
source share
1 answer

One way to do this is to use ValueAnimator:

final SeekBar seekBar = findViewById(R.id.seekBar); ValueAnimator anim = ValueAnimator.ofInt(0,seekBar.getMax()); anim.setDuration(1000); anim.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int animProgress = (Integer) animation.getAnimatedValue(); seekBar.setProgress(animProgress); } }); 

Another way could be (havent test this):

 final SeekBar seekBar = findViewById(R.id.seekBar); ObjectAnimator anim = ObjectAnimator.ofFloat(seekBar, "progress", 0,seekBar.getMax()); anim.setDuration(10000); anim.start(); 
+13
source

Source: https://habr.com/ru/post/917249/


All Articles