Skip to content

Fix Android camera preview containment#314

Merged
jfversluis merged 1 commit into
mainfrom
jfversluis/fix-android-preview-containment
Jun 18, 2026
Merged

Fix Android camera preview containment#314
jfversluis merged 1 commit into
mainfrom
jfversluis/fix-android-preview-containment

Conversation

@jfversluis

Copy link
Copy Markdown
Collaborator

Summary

  • Configure Android CameraX PreviewView to use compatible rendering so the preview surface behaves like a normal clipped view in constrained MAUI layouts.
  • Enable child, padding, and outline clipping on the PreviewView so grids, popups, and borders can contain the camera preview bounds.
  • Keep the existing default PreviewView scale behavior; this does not switch to FitCenter or introduce letterboxing.

Validation

  • dotnet build ZXing.Net.MAUI/ZXing.Net.MAUI.csproj -f net10.0-android
  • dotnet test ZXing.Net.MAUI.Tests/ZXing.Net.MAUI.Tests.csproj

Risk

  • This relies on CameraX compatible mode (TextureView) instead of the default performance path, which favors layout correctness/clipping over possible SurfaceView performance optimizations.

Fixes #4
Fixes #71
Fixes #250
Fixes #285

Configure CameraX PreviewView to use compatible rendering and clip its child surface to the view bounds so Android previews stay contained in constrained layouts such as grids, popups, and borders.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jfversluis

Copy link
Copy Markdown
Collaborator Author

Thanks @viniciusverasdossantos, @MaximG1234, @Cav-jj, and @alberk8 for reporting the Android preview containment issues that helped narrow this down.

This PR keeps the existing fill/crop preview behavior but changes the Android CameraX PreviewView rendering/clipping setup so it should stay inside constrained layouts like grids, popups, and borders. Once the PR artifacts are available, could you please try them in your affected layouts and let us know whether the preview is now contained correctly on your devices?

@jfversluis jfversluis merged commit 98a4c69 into main Jun 18, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant