피벗 지점에서 회전 캔버스에 적용 할 때 제대로 작동하지 않습니다. 회전 지점이 변경되지 않은 것처럼 보입니다. 나는 매트릭스를 사용하여 이것을 적용했지만 그때는 캔버스로 회전하는 것을 찾는 것이 좋았다. 비트 맵을 회전하고 UI에 다른 이미지가 있습니다. 나는 회전 할 필요가있는 비트 맵을 그리기 직전에 캔버스를 회전시키고있다.setRotate (float degrees, float px, float py)를 사용하여 캔버스를 회전 하시겠습니까? 피벗 arround ... 나를 위해 올바르게 작동하지 않습니다
@Override protected void onDraw(Canvas canvas)
{
/* * draw the background */
canvas.drawBitmap(mWood, 0, 0, null);
/* * compute the new position of our object, based on accelerometer */
final ParticleSystem particleSystem = mParticleSystem;
final long now = mSensorTimeStamp + (System.nanoTime() - mCpuTimeStamp);
final float sx = mSensorX;
final float sy = mSensorY;
particleSystem.update(sx, sy, now);
final Bitmap bitmap = mBitmap;
final Bitmap bitmapOvel = mBitmapOvel;
Paint p = new Paint();
p.setStyle(Style.FILL);
p.setColor(Color.GREEN);
canvas.drawBitmap(mWoodDial, 10, centerY - centerX + 20, null);
p.setColor(Color.RED);
p.setStyle(Style.FILL_AND_STROKE);
if (height <= 320)
{
p.setTextSize(14f);
}
else if (height <= 480)
{
p.setTextSize(18f);
}
else
{
p.setTextSize(26f);
}
String ss = Html.fromHtml(xx + "° && " + yy + "°") .toString();
canvas.drawBitmap(mBitmapOvelAlter, centerX + xx * 1.7f - 15f, centerY + 6f - yy, null);
canvas.rotate(xx, centerX, centerY);
p.setAntiAlias(true);
p.setFilterBitmap(true);
p.setDither(true);
canvas.save();
canvas.drawBitmap(mWoodDial1, 10, centerY - centerX + 20, p);
canvas.restore();
System.out.println("xx:" + xx + "::.. yy:" + yy);
// and make sure to redraw asap
invalidate();
}
당신은 올바른 방향으로 나아 가지 않을 것입니다. onDraw에서 무효화를 호출하지 마십시오. 끊임없이 무언가를 업데이트 할 필요가 있다면 당신은 틱하고 무효화하는 타이머를 가져야한다. 더 좋게는 서페이스 뷰를 사용하고 드로잉 루프를 직접 처리하십시오. – dcow