2011-06-06 73 views
0

ImageView不旋轉?ImageView不旋轉

ImageView arrow1; 
arrow1 =(ImageView) findViewById(R.id.arrow1); 
Matrix mtx = new Matrix(); 
mtx.postRotate(90); 
arrow1.setImageMatrix(mtx); 

有什麼建議嗎?

+0

沒有ü嘗試嗎? – Lavanya 2011-06-06 10:58:57

+0

如果我需要像postRotate(102)那樣以不同的角度旋轉圖像。 – 2011-09-17 07:29:07

回答

0

現在,圖像旋轉

arrow1 = (ImageView) findViewById(R.id.arrow1); 
bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.arrow1); 
bmpWidth = bitmap.getWidth(); 
bmpHeight = bitmap.getHeight(); 
float curScale = 1F;   
Matrix matrix = new Matrix(); 
matrix.postScale(curScale, curScale); 
matrix.postRotate(90); 
if(resizedBitmap!=null){ 
resizedBitmap.recycle(); 
} 
resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bmpWidth, bmpHeight, matrix, true); 
arrow1.setImageBitmap(resizedBitmap);