簡體   English   中英

如何在Android Studio中的imageView上添加具有不同軸的兩個旋轉?

[英]how to add two rotation with different pivots on a imageView in android studio?

我試圖在ImageView上進行旋轉,每個旋轉都有其自己的pivot 一個意味着具有默認樞軸,而另一個具有(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();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM