【发布时间】:2015-03-17 07:49:05
【问题描述】:
我只想旋转an image from min to max。但为此,我使用了多张图片来展示进度。有人可以建议我一种使用单个图像的方法。可以从最小到最大的角度旋转。
我知道有两种可能的方法来实现它。
- 使用动画类
- 自定义视图
我只是想使用 SeekBar 以任意数量的步骤旋转此图像。
我怎样才能做到这一点?
旋转图像
private void rotate(float degree) {
final RotateAnimation rotateAnim = new RotateAnimation(0.0f, degree,
RotateAnimation.RELATIVE_TO_SELF, 0.5f,
RotateAnimation.RELATIVE_TO_SELF, 0.5f);
rotateAnim.setDuration(0);
rotateAnim.setFillAfter(true);
imgview.startAnimation(rotateAnim);
}
第二种方法
imageView.setRotation(angle); // but requires API >= 11
我可以使用矩阵
Matrix matrix = new Matrix();
imageView.setScaleType(ScaleType.MATRIX); //required
matrix.postRotate((float) angle, pivX, pivY);
imageView.setImageMatrix(matrix);
我如何将开始和结束角度分别设置为 SeekBar 最小值和最大值。哪种方法更好,我是否必须把它放在FrameLayout 让它rotate freely。
【问题讨论】:
标签: java android android-animation android-custom-view