2016-01-06 84 views
0

我想旋轉Android Wear手錶錶盤(位圖)的時鐘手,但我似乎無法弄清楚如何設置特定點使用Matrix.rotate旋轉的手。 (手中的旋轉點距底部約20像素)。Android Wear使用矩陣旋轉特定樞軸點上的手

我的理解是我需要設置樞軸點......以及旋轉點(centerX,centerY)。然後旋轉一個特定的程度。

這是我得到的,但樞軸點不起作用。

// set pivot point 
    handSecondMatrix.setTranslate(mCenterX - (mHandSecondBitmap.getWidth() * 0.375f), (mCenterY - (mHandSecondBitmap.getHeight() * 0.8744f))); 

// set rotation  
    handSecondMatrix.setRotate(rotation); 

// set center point to rotate on 
    handSecondMatrix.postTranslate(mCenterX, mCenterY); 

// draw hand 
    canvas.drawBitmap(mHandSecondBitmap, handSecondMatrix, mHandSecondPaintBitmap); 

回答

0

明白了這個工作:

// Draw Hour Hand 
handHourMatrix.reset(); 
handHourMatrix.setRotate(rotHr, mHandHourBitmapAmbient.getWidth()/2, mHandHourBitmapAmbient.getHeight() * 0.958f); 
handHourMatrix.postTranslate(mCenterX - (mHandHourBitmapAmbient.getWidth()/2), mCenterY - (mHandHourBitmapAmbient.getHeight() * 0.958f)); 
canvas.drawBitmap(mHandHourBitmapAmbient, handHourMatrix, mHandHourPaintBitmap);