Using View Animation

2

I would like to know how you would use View Animation to simulate a GIF.

For example: I have a photo of a sword, this sword is up, so do something like that to go right, clockwise, going around and going back to its original position.

Has anyone worked this way?

    
asked by anonymous 06.08.2015 / 15:20

1 answer

1

Android provides various types of animations that can be applied to an ImageView . The one that applies to you is RotateAnimation .

Its use is done in 3 steps:

1 - Create an object of type RotateAnimation

//Cria uma animação de rotação desde de 0º a 360º com o eixo de rotação no centro da imagem.
RotateAnimation animation = new RotateAnimation(0f, 360f,
                                                Animation.RELATIVE_TO_SELF, 0.5f, 
                                                Animation.RELATIVE_TO_SELF, 0.5f);

2 - Define the properties of the animation.

// 3 segundos.
long tempo = 3000;

//Define que a animação se processa de forma linear
animation.setInterpolator(new LinearInterpolator());

//Define o tempo da animação 
animation.setDuration(tempo);

3 - Start it.

imageView.startAnimation(animation);
    
06.08.2015 / 17:55