Compose CameraXViewfinder aspect ratio

39 views
Skip to first unread message

Nathan AUDVARD

unread,
Nov 17, 2025, 11:48:48 AMNov 17
to Android CameraX Discussion Group
Hi,

Is there an easy way to have a CameraXViewfinder that match (and fit) the surface requested ?

I tried to divide surface's width by height and using it as aspect ratio modifier, but it only works in landscape. Since CameraXViewfinder has a fillMaxSize, setting width modifier with IntrinsicSize doesn't work either.

Thanks.

Charcoal Chen

unread,
Nov 20, 2025, 5:06:07 AMNov 20
to Android CameraX Discussion Group, n.au...@dental-monitoring.com
Hi,

The resolution from the SurfaceRequest is a size expressed in the device' camera sensor coordinate system. You can register the TransformationInfoListener by SurfaceRequest#setTransformationInListener(), and get the rotation degrees info by TransformationInfo#getRotationDegrees() to know whether you should flip the width and height values to adjust your CameraXViewfinder to match the surface resolution.
Reply all
Reply to author
Forward
0 new messages