让一个圆形图片围绕圆心(轴心)旋转一定的角度,要用到什么哪个函数?每点击一次上下键就旋转一定角度!谢谢

解决方案 »

  1.   

    两种方法
    1.canvas.rotate(角度);
    2.使用Matrix进行矩阵变化.
      

  2.   

    /**
         * 图片旋转指定角度
         * @param resizedBitmap 位图
         * @param image View
         * @param scaleAngle  旋转角度值
         * @return
         */
    private ImageView pointerRotation(Bitmap resizedBitmap,ImageView image,int scaleAngle)
    {

    //scaleAngle=360-45+scaleAngle;

         int ScaleTimes=1;
         
         int oldWidth = resizedBitmap.getWidth();
         int oldHeight = resizedBitmap.getHeight() ; 
         
     /* ScaleTimes=1,维持1:1的宽高比例*/ 
         int newWidth = resizedBitmap.getWidth()*ScaleTimes ;
         int newHeight = resizedBitmap.getHeight()*ScaleTimes ; 
         
         float scaleWidth = (float) newWidth / resizedBitmap.getWidth();
         float scaleHeight = (float) newHeight / resizedBitmap.getHeight(); 
         
         Matrix matrix = new Matrix(); 
         /* 使用Matrix.postScale设定维度 */
         matrix.postScale(scaleWidth, scaleHeight);
         /* 使用Matrix.postRotate方法旋转Bitmap*/
         //matrix.postRotate(5*ScaleAngle); 
         matrix.setRotate(scaleAngle); 
         /* 建立新的Bitmap对象 */
         resizedBitmap =Bitmap.createBitmap(resizedBitmap, 0, 0, oldWidth, oldHeight, matrix, true);
         /**/ 
         BitmapDrawable myNewBitmapDrawable =new BitmapDrawable(resizedBitmap); 
         image.setImageDrawable(myNewBitmapDrawable); 
         
        
         //imageView1.image.setBackgroundResource(R.drawable.mainbuttoneffect);
        
         int h=resizedBitmap.getHeight();
         int w=resizedBitmap.getWidth();
         image.setLayoutParams ( new AbsoluteLayout.LayoutParams (w,h,(int) (screenW-w)/2,(int)(screenH-2*h)/2 )); 
         
         SourceLocationX=(screenW-w)/2;
         SourceLocationY=(screenH-2*h)/2;
         
       
         return image;  
    }zh
    这是我从程序中截取的函数,试着改成你想要的,应该可以满足你的