在我的代码中,当我们点击放大/缩小控制时,相机放大/缩小控制不起作用,没有错误,但相机预览没有放大/缩小
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();
}
答案 0 :(得分:0)