如何在android&中通过触摸旋转图像视图还可以增加imageview

时间:2016-10-17 11:45:06

标签: android imageview

我正试图通过手指触摸来旋转ImageViewenter image description here

但目前它正从图像的中心点旋转圆形。

public boolean onTouch(final View v, MotionEvent event) {
    wheel.setRotation((int)event.getRawX());
} 

1 个答案:

答案 0 :(得分:0)

在onClickListener中尝试使用此代码。

RotateAnimation rotateImage = new RotateAnimation(0.0f, 90,
                        RotateAnimation.RELATIVE_TO_SELF, 0.5f,
                        RotateAnimation.RELATIVE_TO_SELF, 1f);

    rotateImage.setStartOffset(0);
    rotateImage.setDuration(1500); 
    rotateImage.setFillAfter(true);
    rotateImage.setInterpolator(YourActivity.this, android.R.anim.decelerate_interpolator);

    imageView.startAnimation(rotateImage);