2016-01-06 117 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);