Quiero aumentar la velocidad de rotación. ¿Cómo puedo aumentar la velocidad de rotación de ImageView en este código? Alguien, por favor, ayúdame. Necesito ayuda con este código. Gracias por adelantado.
public class MainActivity extends Activity { ImageView img_one; Button btn_one; Random r; int angle; boolean restart=false; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); img_one = (ImageView) findViewById(R.id.imageView_ring); r=new Random(); btn_one = (Button) findViewById(R.id.btn_1); btn_one.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (restart){ angle=angle & 360; angle=r.nextInt()+360; RotateAnimation rotate=new RotateAnimation(angle,360,RotateAnimation.RELATIVE_TO_SELF,0.5f, RotateAnimation.RELATIVE_TO_SELF,0.5f); rotate.setFillAfter(true); rotate.setDuration(50); rotate.setInterpolator(new AccelerateDecelerateInterpolator()); img_one.startAnimation(rotate); restart=false; }else { angle=r.nextInt()+360; RotateAnimation rotate=new RotateAnimation(0,angle,RotateAnimation.RELATIVE_TO_SELF,0.5f, RotateAnimation.RELATIVE_TO_SELF,0.5f); rotate.setFillAfter(true); rotate.setDuration(50); rotate.setInterpolator(new AccelerateDecelerateInterpolator()); img_one.startAnimation(rotate); restart=true; } } }); }}
Si desea rotar más rápido, debe reducir la duración de la animación. Actualmente lo tienes configurado para que dure 50 milisegundos:
rotate.setDuration(50);pero puede establecer la duración según lo que necesite para lograr el efecto deseado.