【问题标题】:How do I rotate objects 180 degrees on android?如何在 android 上将对象旋转 180 度?
【发布时间】:2016-02-13 09:00:00
【问题描述】:

如何将 .png imageButton 旋转 180 度?我用动画尝试这个,但是当动画结束时,它开始了。谢谢..

【问题讨论】:

  • 您能否澄清一下。你的意思是当动画调用结束时图像开始旋转/转动?也请分享你的代码,它会让事情变得更容易!

标签: java android rotation png imagebutton


【解决方案1】:

您可以使用 ImageView 和 API>=11

mImageView.setRotation(angle);

在 XML 属性中你可以使用android:rotation="90"

您也可以使用Matrix 进行操作

(假设 imageViewanglepivotXpivotY 已定义)

 Matrix matrix = new Matrix();
    imageView.setScaleType(ImageView.ScaleType.MATRIX);   //required
    matrix.postRotate((float) angle, pivotX, pivotY);
    imageView.setImageMatrix(matrix);

【讨论】:

    【解决方案2】:

    只需添加以下内容:

    yourAnimation.setFillAfter(true);
    

    如果你想要真实的视图旋转(改变原来的位置),使用ObjectAnimator

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-20
      • 1970-01-01
      • 1970-01-01
      • 2016-08-17
      相关资源
      最近更新 更多