Java 如何在android studio中在imageView上添加两个具有不同枢轴的旋转?

Java 如何在android studio中在imageView上添加两个具有不同枢轴的旋转?,java,android,android-studio,Java,Android,Android Studio,我试图在图像视图上旋转,每个视图都有自己的轴。其中一个具有默认枢轴,而另一个具有(0,0)作为其枢轴。尝试执行此操作时,仅对视图执行最后一次旋转。我怎样才能让它们同时工作 以下是我的尝试: this.animate().rotation(180f).setDuration(0); setPivotX(0); setPivotY(0); this.animate().rotation((float) Math.toDegrees(Math.atan((y2 - y1) / (x2

我试图在
图像视图上旋转,每个视图都有自己的
轴。其中一个具有默认枢轴,而另一个具有(0,0)作为其枢轴。尝试执行此操作时,仅对视图执行最后一次旋转。我怎样才能让它们同时工作

以下是我的尝试:

  this.animate().rotation(180f).setDuration(0);
  setPivotX(0);
  setPivotY(0);
  this.animate().rotation((float) Math.toDegrees(Math.atan((y2 - y1) / (x2 - x1)))).setDuration(0);

这是在实现
imageView

的类的函数中完成的。您应该使用ParallelTransition,下面是我的示例:

ParallelTransition pt = new ParallelTransition();

    RotateTransition rx=new RotateTransition(Duration.seconds(5), this);
    rx.setAxis(Rotate.X_AXIS);

    RotateTransition rz=new RotateTransition(Duration.seconds(5), this);
    rz.setAxis(Rotate.Z_AXIS);

    rx.setFromAngle(0);
    rx.setToAngle(90*xrotate);

    rz.setFromAngle(0);
    rz.setToAngle(90*zrotate);

    pt.getChildren().addAll(rz,rx);

    pt.play();