viewpropertyanimator

How can I repeat a property animation?

℡╲_俬逩灬. 提交于 2019-12-19 17:38:33
问题 I'm doing an animation of bubbles on the screen, but the bubbles stop after finishing the animation time. How do I repeat the animation or make it infinite? bub.animate(); bub.animate().x(x2).y(y2); bub.animate().setDuration(animationTime); bub.animate().setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { animators.add(animation); } @Override public void onAnimationRepeat(Animator animation) { } @Override public void onAnimationEnd(Animator

How to reset view to original state after using animators to animates its some properties?

耗尽温柔 提交于 2019-12-06 18:33:09
问题 I am using animators (ObjectAnimator) to animate few properties (scale, rotate) of a view. Target view is animating properly when ObjectAnimators are set to it. But there is an added requirement to get view to the original position (reset) after a while. I tried to cancel() the animator but it only cancels the animation and doesn't reset the view. Possible solution : creating another animator that does just opposite of the initial animator. Is there any other way to reset it ? 回答1: See the

android animate() withEndAction() vs setListener() onAnimationEnd()

随声附和 提交于 2019-12-04 15:43:21
问题 Often I use ViewPropertyAnimator and set end action using its withEndAction() function like: view.animate().translationY(0).withEndAction(new Runnable() { @Override public void run() { // do something } }).start(); But also you can set end action setting special listener like: view.animate().translationY(0).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { // do something } }); So what is the difference between these two approaches and when

android animate() withEndAction() vs setListener() onAnimationEnd()

£可爱£侵袭症+ 提交于 2019-12-03 09:45:33
Often I use ViewPropertyAnimator and set end action using its withEndAction() function like: view.animate().translationY(0).withEndAction(new Runnable() { @Override public void run() { // do something } }).start(); But also you can set end action setting special listener like: view.animate().translationY(0).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { // do something } }); So what is the difference between these two approaches and when I should use each of them? There is no big difference, take a look at the souce code . Both are

How can I repeat a property animation?

笑着哭i 提交于 2019-12-01 16:47:34
I'm doing an animation of bubbles on the screen, but the bubbles stop after finishing the animation time. How do I repeat the animation or make it infinite? bub.animate(); bub.animate().x(x2).y(y2); bub.animate().setDuration(animationTime); bub.animate().setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { animators.add(animation); } @Override public void onAnimationRepeat(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { } }); Since ViewPropertyAnimator is only good for simple animations, use more advanced

Why does running a second viewpropertyanimation on a view break the animation listeners?

ε祈祈猫儿з 提交于 2019-11-29 17:44:10
I have a strange issue where my onAnimationEnd gets called repeatedly (hence my animation keeps running over and over even though I'm not explicitly calling it). Here is a screen recording of what's happening: https://youtu.be/TfGiLvwLdBM The following is my code: public class MainActivity extends AppCompatActivity { private static final String TAG = "TT_MainActivity"; ActivityMainBinding binding; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); binding = DataBindingUtil.setContentView(this, R.layout

Android - Zoom animation using AnimatorSet

淺唱寂寞╮ 提交于 2019-11-29 11:47:24
问题 The official Zooming a View tutorial uses an AnimatorSet to zoom into a View . It creates the illusion of downward movement as the view expands. Later, the AnimatorSet is simply replayed backwards to create the illusion of zoom-out. What I need to implement is the exact reverse of this. I need to start with an expanded view and shrink it into a smaller view with an upward movement: It doesn't seem that I can use the reversal code in the example. That example assumes that you first zoom into

Android property animation: how to increase view height?

旧时模样 提交于 2019-11-28 16:58:15
How to increase the view height using Property Animations in Android? ObjectAnimator a = ObjectAnimator.ofFloat(viewToIncreaseHeight, "translationY", -100); a.setInterpolator(new AccelerateDecelerateInterpolator()); a.setDuration(1000); a.start(); The translationY actually moves the view not increase the height. How can I increase the height of the view? ValueAnimator anim = ValueAnimator.ofInt(viewToIncreaseHeight.getMeasuredHeight(), -100); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int val =

Why does running a second viewpropertyanimation on a view break the animation listeners?

北城以北 提交于 2019-11-28 12:52:45
问题 I have a strange issue where my onAnimationEnd gets called repeatedly (hence my animation keeps running over and over even though I'm not explicitly calling it). Here is a screen recording of what's happening: https://youtu.be/TfGiLvwLdBM The following is my code: public class MainActivity extends AppCompatActivity { private static final String TAG = "TT_MainActivity"; ActivityMainBinding binding; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState

Android property animation: how to increase view height?

放肆的年华 提交于 2019-11-27 10:06:18
问题 How to increase the view height using Property Animations in Android? ObjectAnimator a = ObjectAnimator.ofFloat(viewToIncreaseHeight, "translationY", -100); a.setInterpolator(new AccelerateDecelerateInterpolator()); a.setDuration(1000); a.start(); The translationY actually moves the view not increase the height. How can I increase the height of the view? 回答1: ValueAnimator anim = ValueAnimator.ofInt(viewToIncreaseHeight.getMeasuredHeight(), -100); anim.addUpdateListener(new ValueAnimator