Android - getAlpha () from animated view

I have an animation:

Animation fadeOut = new AlphaAnimation(1, 0);
fadeOut.setInterpolator(new DecelerateInterpolator());
fadeOut.setDuration(350);
myView.startAnimation(fadeOut);

I am trying to get it Alpha durring Animation as such:

System.out.println(myView.getAlpha());

However, it always returns “1.0” throughout the animation. How can I get the actual alpha value myViewduring the animation process?

+3
source share
1 answer

Using Transformationwith yours AlphaAnimation, you can get the alpha value directly from your object AlphaAnimationinstead View.

Purpose of using transformation:

Defines the transformation that should be applied at one point in time in the animation.


Steps:


: https://sourcegraph.com/android.googlesource.com/platform/frameworks/base/-/blob/core/java/android/widget/ProgressBar.java#L1699 https://developer.android.com/reference/android/view/animation/Animation.html https://developer.android.com/reference/android/view/animation/Transformation.html

+5

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


All Articles