android - Xperia Z full screen camera preview? -
i coding app android uses surfaceview class realize camera preview, works on nexus galaxy , desire hd
the surface view layout width/height attribute match_parent
but encountered problem: on sony xperia z , screen resolution 1080p , largest preview resolution 1280*720
thus, camera preview occupies part of full screen , other space blank.
how can make preview full screen ?
resize surfaceview in landscape mode:
// float camera_ratio = preview_size.width * preview_size / height; viewgroup.layoutparams params = surfaceview.getlayoutparams(); params.height = surfaceview.getholder().getsurfaceframe().height(); params.width = math.round(camera_ratio * params.height); surfaceview.setlayoutparams(params);
or switch around parameters if app in portrait mode.
edit: holy moly, sorry resurrecting half year old question!
Comments
Post a Comment