Android ImageView: How can I get the current rotat

2019-07-03 21:46发布

I rotate an image view to point an arrow in the desired direction. Before performing the next rotation (using RotateAnimation), how can I get the currently rotated angle of the ImageView?

Thanks

2条回答
等我变得足够好
2楼-- · 2019-07-03 22:17

You need store your previous rotation angle in some variable.

查看更多
放我归山
3楼-- · 2019-07-03 22:33

Save rotate angle:

    ImageView arrow = (ImageView) findViewById(R.id.arrow);
    float x = arrow.getPivotX();
    float y = arrow.getPivotY();
    RotateAnimation anim = new RotateAnimation(arrowRotateStartAngle, arrowRotateXAngle, arrow.getWidth()/2, arrow.getHeight()/2);
    anim.setFillAfter(true);
    anim.setDuration(1000);
    arrow.startAnimation(anim);

    temRotate = arrowRotateStartAngle;
    arrowRotateStartAngle = arrowRotateXAngle;
    arrowRotateXAngle = temRotate;
查看更多
登录 后发表回答