1
可能重複:
Camera preview Zoom in/out not working on click相機放大/縮小控制不工作
在我的代碼相機放大/縮小控制不點擊的工作,當我們輸入/輸出點擊放大控制在那裏沒有錯誤,但相機預覽沒有放大/縮小
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
Camera.Parameters parameters = camera.getParameters();
ZoomControls zoomControls =(ZoomControls)findViewById(R.id.CAMERA_ZOOM_CONTROLS);
if(params.isZoomSupported()){
maxZoomLevel = params.getMaxZoom();
zoomControls.setIsZoomInEnabled(true);
zoomControls.setIsZoomOutEnabled(true);
zoomControls.setOnZoomInClickListener(new OnClickListener(){
public void onClick(View v){
if(currentZoomLevel < MAX_ZOOM){
currentZoomLevel++;
camera.startSmoothZoom(currentZoomLevel);
}
}
});
zoomControls.setOnZoomOutClickListener(new OnClickListener(){
public void onClick(View v){
if(currentZoomLevel > 0){
currentZoomLevel--;
camera.startSmoothZoom(currentZoomLevel);
}
}
});
}
camera.setParameters(parameters);
camera.startPreview();
}
請格式化您的代碼以可讀的方式... – m0skit0