Android ImageView: How can I get the current rotation angle?

回眸只為那壹抹淺笑 提交于 2019-12-23 20:08:39

问题


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


回答1:


You need store your previous rotation angle in some variable.




回答2:


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;


来源:https://stackoverflow.com/questions/9755088/android-imageview-how-can-i-get-the-current-rotation-angle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!