以下は、SurfaceView のサブクラスでオーバーライドされた dispatchDraw です。サーフェスのパラメーターを変更しようとしています (ビデオ プレビューのサブセクションのみを取得します。
@オーバーライド
public void dispatchDraw (Canvas canvas) {
Log.d(TAG,"**************inside dispatchDraw************");
int VIEW_WIDTH = canvas.getWidth();
int VIEW_HEIGHT = canvas.getHeight();
Log.d(TAG,"**************inside dispatchDraw************" + Integer.toString(VIEW_WIDTH) + " ," + Integer.toString(VIEW_HEIGHT));
int newWidth = 400;
int newHeight = 240;
float scaleWidth = ((float) newWidth) / VIEW_WIDTH;
float scaleHeight = ((float) newHeight) / VIEW_HEIGHT;
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
canvas.setMatrix(matrix);
super.dispatchDraw(canvas);
Log.d(TAG,"**************inside dispatchDraw-after super************");
}
上記のコードが SurfaceView の寸法をまったく変更しないのはなぜですか?