October 2017
Intermediate to advanced
294 pages
6h 49m
English
If we want to animate objects directly instead of properties, we could use the ObjectAnimator class. ObjectAnimator is a subclass of ValueAnimator and uses the same functionality and features, but adds the ability to animate objects properties by name.
For instance, to show how it works, we could animate a property of our own View this way. Let's add a small rotation to the whole canvas, controlled by the canvasAngle variable:
float canvasAngle;
@Override
protected void onDraw(Canvas canvas) {
canvas.save();
canvas.rotate(canvasAngle, getWidth() / 2, getHeight() / 2);
...
canvas.restore();
}
We've got to create a setter and a getter with the right name: set<VariableName>and get<VariableName> in camel case, and in our specific ...
Read now
Unlock full access