2011-12-17 52 views

回答

3

可能是ü有助于旋转图像.......

RotateAnimation rotate = new RotateAnimation(180, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); 
rotate.setDuration(500); 
imageview.startAnimation(rotate); 

前两个参数为开始和程度的结束。

6

使用矩阵,你可以做到这一点,

喜欢的东西,

img=(ImageView)findViewById(R.id.ImageView01); 
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.refresh); 
// Getting width & height of the given image. 
int w = bmp.getWidth(); 
int h = bmp.getHeight(); 
// Setting post rotate to 90 
Matrix mtx = new Matrix(); 
mtx.postRotate(90); 
// Rotating Bitmap 
Bitmap rotatedBMP = Bitmap.createBitmap(bmp, 0, 0, w, h, mtx, true); 
BitmapDrawable bmd = new BitmapDrawable(rotatedBMP); 

img.setImageDrawable(bmd); 

或使用动画

RotateAnimation rAnim = new RotateAnimation(0, 359, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); 
rAnim.setDuration(1000); 
imageview.startAnimation(rAnim); 

编辑:看看这个问题也How to make a smooth image rotation in Android?

Animating and rotating an image in a Surface View

+0

+1供引用:“如何在Android中进行平滑的图像旋转?” – cbrulak 2012-08-01 05:42:50

1

这是帽子我已经做 定时器每隔100micro秒 小时后调用pondraw mthod,W是图像

    new CountDownTimer(2000, 100) { 

     public void onTick(long millisUntilFinished) { 
      degrees=degrees +(rm.nextFloat()*100); 
      postInvalidate(); 
     } 

     public void onFinish() { 

     } 
    }.start(); 

把这个代码中的OnDraw方法的高度和宽度

Matrix m = new Matrix(); 
m.setRotate(degrees,w/2,h/2); 
    bmp=BitmapFactory.decodeResource(context.getResources(),R.drawable.wfortune_wheel); 
canvas.drawBitmap(bmp, m, pb); 

}