This seems very simple: I'm trying to set the interpolator to be used for an animation in my App. I need to set this in the Java code, not the XML (It will change according to various things).
From the android website, I've found setInterpolator()
However, I'm not sure how to use this.
I've tried just feeding in the interpolar name (ie. BounceIterpolator
), but this did nothing.
I tried R.anim.BounceIterpolator
, but Intellisense said anim cannot be resolved or is not a field
.
So how can I set the interpolator from the Java?
An interpolator defines the rate of change of an animation. This allows the basic animation effects (alpha, scale, translate, rotate) to be accelerated, decelerated, repeated, etc.
Tween Animation takes some parameters such as start value , end value, size , time duration , rotation angle e.t.c and perform the required animation on that object. It can be applied to any type of object. So in order to use this , android has provided us a class called Animation.
The pivotX and pivotY is the central point of the animation. So for example if you want to do Zoom In animation you can use this <? xml version="1.0" encoding="utf-8"?> <
You can find the anim folder by navigating to the app > res > anim. Then go to the anim > right-click > New > Animation Resource File as shown in the below image.
setInterpolator(new BounceInterpolator());
anim.setInterpolator(context, android.R.anim.bounce_interpolator);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With