The document discusses different animation techniques for Android, including property animation, view animation, object animator, view property animator, value animator, and physics-based animation using the support library. It provides code examples for creating animations that change the alpha, scale, rotation, and translation of views. It also covers using interpolators, listeners, spring animations, and fling animations to control the motion and timing of animations.
27. ObjectAnimator (Código)
// play together
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.setDuration(600); // 600 millisegundos
// executa as animacoes todas ao mesmo tempo
animatorSet.playTogether(translationAnimator, rotationAnimator);
animatorSet.start();
45. SpringAnimation
private View myView;
private void createSimpleSpringAnimation() {
// calcula a posição Y - convert 100dp para pixels
float endPosition = Utils.dpToPx(this, 100);
// cria a animacao
SpringAnimation anim = new SpringAnimation(myView,
SpringAnimation.TRANSLATION_Y,
endPosition
);
// altera o damping (amortecimento)
anim.getSpring().setDampingRatio(SpringForce.DAMPING_RATIO_MEDIUM_BOUNCY);
// altera o stiffness (rigidez)
anim.getSpring().setStiffness(SpringForce.STIFFNESS_LOW);
// inicia na animcação
anim.start();
}