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

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -