开发者社区 问答 正文

旋转图像到指定的方向

我想旋转一个箭头来指定一些指定的位置:

float bearing = myLoc.bearingTo(mecca);
      RotateAnimation rotate = new RotateAnimation(0, bearing, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
      arrow.setAnimation(rotate);
      rotate.start();

现在是旋转,但是不到一秒又回到了原来的位置。如何让它像指南针一样旋转?

展开
收起
蛮大人123 2016-06-16 13:35:42 1993 分享 版权
1 条回答
写回答
取消 提交回答
  • 我说我不帅他们就打我,还说我虚伪

    一个简单的方法来选择一个imageView :

    Matrix matrix=new Matrix();
    imageView.setScaleType(ScaleType.MATRIX);   //required
    matrix.postRotate((float) angle, pivX, pivY);
    arrow.setImageMatrix(matrix);
    2019-07-17 19:40:44
    赞同 展开评论
问答地址: