2011-12-17 13 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); 

最初の二つのパラメータ画像を回転するUに役立つかもしれません。あなたがそれを行うことができマトリックスを使用して

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); 

EDIT:この質問で見てもHow to make a smooth image rotation in Android?

Animating and rotating an image in a Surface View

+0

+1:「Androidで滑らかな画像ローテーションを作成する方法」 – cbrulak

1

これは私が 画像の高さと幅が

    new CountDownTimer(2000, 100) { 

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

     public void onFinish() { 

     } 
    }.start(); 

あるWタイマが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); 
をこのコードを入れて、すべての100micro秒 時間後pondrawのmthodを呼び出しを行っている帽子です

}

関連する問題