How can I create an automatic zoom and default zoom with cameraX/CameraController on Java?

Skip to first unread message

Andre Tauk

May 14, 2021, 5:18:14 PMMay 14
to Android CameraX Discussion Group

(I posted this question on stackOverflow, but got no answer)

This is the code I'm using, a can only change the zoom level by sliding the seekbar, not automatically. Neither select a default zoom level.

I'm using this example of cameraX/CameraController:

SeekBar linearZoomSlider = findViewById(; linearZoomSlider.setOnSeekBarChangeListener(

new SeekBar.OnSeekBarChangeListener() {

  @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean b) { checkFailedFuture(mCameraController.setLinearZoom(
 (float) progress / seekBar.getMax()
)); }

  @Override public void onStartTrackingTouch(SeekBar seekBar) { 

  @Override public void onStopTrackingTouch(SeekBar seekBar) { 
} });

Patrick Liao

May 15, 2021, 11:42:57 AMMay 15
to Android CameraX Discussion Group,

Would you provide more information about "automatic"? (i.e. what do you mean by "automatic"?) 
And for changing zoom ratio, you can do (ProcessCameraProvider object).getCameraControl().setZoomRatio(float ratio) directly if this is what you are looking for.

Patrick Liao

Patrick Liao

May 15, 2021, 11:47:14 AMMay 15
to Android CameraX Discussion Group, Patrick Liao,
Sorry for the typo :(

I mean  ( object).getCameraControl().setZoomRatio(float ratio), and the Camera object could be obtained ProcessCameraProvider.bindToLifeCycle(args) (The same one for binding CameraX use cases and this function would return Camera object). 

Reply all
Reply to author
0 new messages