CameraX OS 10 out of Bound

Skip to first unread message

Sep 11, 2023, 10:44:28 AMSep 11
to Android CameraX Discussion Group
      I am using Camerax API for image capturing. PreviewView Android 10 is extending outside the bounds, see the below screenshot before and after image capture.
And try the scaletype for ,
//if using this top portion aligned properly
viewFinder!!.scaleType = PreviewView.ScaleType.FILL_START
//if using this bottom portion aligned properly
 viewFinder!!.scaleType = PreviewView.ScaleType.FILL_END  

 how to use both scale type or any other options are available.

Code snippet

val cameraProvider: ProcessCameraProvider = cameraProviderFuture.get()
            val preview = Preview.Builder()
                //.setTargetResolution(Size(frame_rect!!.width, frame_rect!!.height))
                .also {
            imageCapture = ImageCapture.Builder().build()

            val imageAnalysis = ImageAnalysis.Builder()
            imageAnalysis.setAnalyzer(cameraExecutor, ImageAnalysis.Analyzer { image ->
                Log.d("IVYCAMERA", "Captured Image...!!!")
                // insert your code here.
            val cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA

            try {
                // Unbind use cases before rebinding
                camera = cameraProvider.bindToLifecycle(
                    this, cameraSelector, imageAnalysis, preview, imageCapture
            } catch (exc: Exception) {
                Log.e(TAG, "Use case binding failed", exc)

        }, Co



Xi Zhang (张熹)

Sep 11, 2023, 11:31:56 AMSep 11
to, Android CameraX Discussion Group
Does it only happen on Android 10, not other versions? Are both the images screenshots for preview, or is the second one a capture image? If you are looking for a WYSIWYG effect across preview and image capture, I would suggest using the CameraController API. You can find a code sample here.

Otherwise, if you can upload a minimal reproducible example to GitHub, I can take a look.

You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Manikandan R

Sep 12, 2023, 1:40:53 AMSep 12
to Xi Zhang (张熹), Android CameraX Discussion Group
Hi, Xi Zhang
                    Thanks for the reply.
Does it only happen on Android 10, not other versions?- All the device, I have Android 10 just now check other device.

Are both the images screenshots for preview, or is the second one a capture image?
First one previewView and second one captured image(after taking photo).

Yes, I am looking  WYSIWYG effect across preview and image capture.

GitHub Link:

Thanks & Regards,
R. Manikandan

Xi Zhang (张熹)

Sep 12, 2023, 5:36:08 PMSep 12
to Manikandan R, Android CameraX Discussion Group
If it's WYSIWYG you are looking for, you need to either use LifecycleCameraController or UseCaseGroup. (LifecycleCameraController is a high level API that uses UseCaseGroup internally)

Once they are used, the image saved will be cropped to match the visible rect of PreviewView.
Reply all
Reply to author
0 new messages