CameraX Customization: PreviewView, Size & Resolution

Nathan Sokalski 4,121 Reputation points
2022-09-30T18:04:26.733+00:00

I am trying to figure out how to customize the CameraX components of my app. I have figured out how to display the preview using the PreviewView view & take a picture, but I am trying to figure out how to do the following:

  1. Make the PreviewView use the remaining area of the screen. I have tried using layout_rowWeight, but that does not seem to work. I have also tried using things like layout_gravity="Fill", but with no success.
  2. Make the size of the picture taken match the size of the PreviewView. Everything that is visible in the PreviewView MUST be included in the picture that is taken.
  3. Use the maximum resolution. The picture from the camera is not being saved to storage (it is temporary), so file size is not a concern.

If the available sizes are restricted to predefined values, I can deal with that by manually calculating which one will use the maximum amount of the PreviewView. To sum it up, I need to use the maximum amount of space at the maximum resolution. Any ideas? Are there any good tutorials on how to do these things? Thanks.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,298 questions
{count} votes