Verschieben Sie ein Bild in kreisförmigen Pfad in android

Ich habe ein Bild, ich wollte, um es in kreisförmigen Pfad onClick() - Ereignis der Schaltfläche, ohne animation,

Ich weiß nicht, wie es zu tun.. Hilfe??


Dies ist meine main Klasse

public class MainActivity extends Activity {
MyAnimation animation;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    animation =new MyAnimation ();

}

und ich bin mithilfe von code, die Sie als

public class MyAnimation extends Animation {
float cx,cy,prevX,prevY,r;

@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    super.applyTransformation(interpolatedTime, t);

    float angle = (float) (interpolatedTime * 2 * Math.PI);
    //r = radius, cx and cy = center point, a = angle (radians)
    float x = (float) (cx + r * Math.cos(angle)) ; 
    float y = (float) (cy + r * Math.sin(angle));

    float dx = prevX - x;
    float dy = prevY - y;

    prevX = x;
    prevY = y;

    t.getMatrix().setTranslate(dx, dy);
}

}

Und das ist mein xml-Code des Bildes, das ich mich bewegen wollte, in Runder Form.

<ImageView
    android:id="@+id/myanimation"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:src="@drawable/ic_launcher" />
InformationsquelleAutor Rohit | 2013-11-29
Schreibe einen Kommentar