Rotation image Android Studio
Salut à tous,
Jeune débutant, je cherche comment faire tourner une pièce de monnaie sur sa tranche et non pas en rond avec Android Studio. Voici mon code qui fait tourner la pièce en rond (ce que je ne veux pas faire).
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| coin = (ImageView) findViewById(R.id.coin);
coin.setImageResource(R.drawable.heads);
btn = (Button) findViewById(R.id.btn);
r = new Random();
btn.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
tourner_coin2();
}
});
}
private void tourner_coin2()
{
//
coin.setImageResource(RANDOM.nextFloat() > 0.5f ? R.drawable.heads : R.drawable.tails);
RotateAnimation rotate = new RotateAnimation(360 * 12,0,
RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
rotate.setDuration(2000);
coin.startAnimation(rotate); |
Ce que je cherche à faire est ici (mais sans javafx)
merci bien.