Android - Getalpha() From Animated View
Solution 1:
By using Transformation
with your AlphaAnimation
, you may be able to retrieve alpha value directly from your AlphaAnimation
object instead of your View
.
Purpose of using Transformation:
Defines the transformation to be applied at one point in time of an Animation.
Steps:
Create a new
Transformation.java
class as shown in https://sourcegraph.com/android.googlesource.com/platform/frameworks/base/-/blob/core/java/android/view/animation/Transformation.java.Initialize a
Transformation
object:private Transformation myTransformation; mTransformation = newTransformation();
Using your code:
AnimationfadeOut=newAlphaAnimation(1, 0); fadeOut.setInterpolator(newDecelerateInterpolator()); fadeOut.setDuration(350);
Get the time at which the drawing of the view hierarchy started (in milliseconds):
finallong time = myView.getDrawingTime();
Get the transformation to apply at a specified point in time. Finally, obtain the actual alpha value during the animation:
fadeOut.getTransformation(time, myTransformation); finalfloat myAlphaValue = myTransformation.getAlpha();
Resources: https://sourcegraph.com/android.googlesource.com/platform/frameworks/base/-/blob/core/java/android/widget/ProgressBar.java#L1699https://developer.android.com/reference/android/view/animation/Animation.htmlhttps://developer.android.com/reference/android/view/animation/Transformation.html
Post a Comment for "Android - Getalpha() From Animated View"