PreviewView Not Updated After Calling SetLinearZoom

Nathan Sokalski 4,116 Reputation points

I am trying to zoom in/out on PreviewView using SetLinearZoom. I do this using the following line of code:


pvPreview is my PreviewView, this.pvPreview.Controller has been set to a LifecycleCameraController, and value is a float from 0.0 to 1.0, but my PreviewView is not updated. Is there something else I need to do?

A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,293 questions
Microsoft Technologies based on the .NET software framework.
3,365 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 68,261 Reputation points Microsoft Vendor


    You need to get CameraControl, then you can set the SetLinearZoom.

    Firstly, you need to find the cameraProvider.BindToLifecycle, then get the CameraControl like following code.

    // Bind use cases to camera
    CameraControl = cameraProvider.BindToLifecycle(this, cameraSelector, preview, imageCapture, imageAnalyzer).CameraControl;

    In the end, you can setLinearZoom, for testing, I change the linearzoom in the button click event like following code.

    AndroidX.Camera.Core.ICameraControl  CameraControl;
            float zoomrate = 0.1f;
            private void Camera_Move_button_Click(object sender, System.EventArgs e)
                zoomrate += 0.1f;

    Best Regards,

    Leon Lu

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful