Matrix 클래스를 사용하여 비트 맵 그리기에서 이러한 작업을 수행 할 수 있습니다.
뭔가 아래
Paint paint = new Paint();
paint.setAntiAlias(true);
Matrix needleTransMatrix = new Matrix();
needleTransMatrix.postRotate(rotationAngle,needleImage.getWidth()/2,needleImage.getHeight());
needleTransMatrix.postTranslate(centerX+METER_OFFSET-needleImage.getWidth()/2, centerY-needleImage.getHeight());
Matrix dialTransMatrix = new Matrix();
dialTransMatrix.postRotate(rotationAngle,dialImage.getWidth()/2,dialImage.getHeight()/2);
dialTransMatrix.postTranslate(METER_OFFSET,0);
canvas.drawBitmap(bgImage, METER_OFFSET, 0, paint);
canvas.drawBitmap(dialImage, dialTransMatrix, paint);
canvas.drawBitmap(needleImage, needleTransMatrix, paint);
처럼 어느 대해 내가이 scalling에 의해 한 번에 하나의 순간을 가져올 수 있습니다 매트릭스를 사용하여 시도에 대한
private class AnimationThread extends Thread{
private boolean isRunning = true;
private int destinationNeedlePosition = NEEDLE_POSITION_ENQURIES;
public AnimationThread(int destinationNeedlePosition) {
this.destinationNeedlePosition = destinationNeedlePosition;
}
public void cancelAnimation(){
isRunning = false;
}
@Override
public void run() {
int destinationAngle = destinationNeedlePosition *45;
while(isRunning && destinationAngle != rotationAngle){
if(destinationAngle > rotationAngle)
rotationAngle++;
else
rotationAngle--;
postInvalidate();
try {
sleep(10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
넵를 이야기하고 도면 스레드입니다 .. 그것은 매끄러운 뒤집기 느낌을주지 않을 것이다! – pvn
당신은 하나의 위치에서 다른 위치로의 전환을 수행하고 위치를 보간 할 스레드를 생성해야합니다. 이 방법으로 미터의 바늘을 회전시킨 것과 같은 일입니다. –
왜 2 개의 행렬을 사용하고 있습니까? – pvn