Wie dreht man ein Android-Symbol auf seinem Mittelpunkt?

Ich habe Folgendes geschrieben, um mein Symbol in der Mitte des Bildschirms zu drehen, und stattdessen dreht es sich um die linke obere Ecke (d. H. Ursprung x = 0, y = 0 in ImageView). Es sollte einfach sein, einige Attribute von ImageView oder RotateAnimation festzulegen, aber ich kann es nicht herausfinden.

public class IconPromoActivity extends Activity {
    private static final float ROTATE_FROM = 0.0f;
    private static final float ROTATE_TO = -10.0f * 360.0f;// 3.141592654f * 32.0f;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        ImageView favicon = (ImageView) findViewById(R.id.favicon);

        RotateAnimation r; // = new RotateAnimation(ROTATE_FROM, ROTATE_TO);
        r = new RotateAnimation(ROTATE_FROM, ROTATE_TO, 0, 0, 40, 0);
        r.setDuration((long) 2*1500);
        r.setRepeatCount(0);
        favicon.startAnimation(r);
    }
}

Antworten auf die Frage(6)

Ihre Antwort auf die Frage