确定的Android设备上的相机高度和宽度 [英] Determine Android Device's Camera Height and Width
本文介绍了确定的Android设备上的相机高度和宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我努力想在一个解决方案,应用程序的屏幕尺寸将是灵活的设备不同的屏幕尺寸。我想获得该设备的摄像头的高度和宽度。有,我们可以在Java中,获取设备的摄像机的高度和宽度,并返回值将被分配给变量CAMERA_WIDTH和CAMERA_HEIGHT调用一个函数?或任何方式做到这一点?除了与实数分配它。谢谢!
I was trying to think over of a solution that an application's screen size will be flexible on different screen sizes of devices. I thought of getting the device's camera height and width. Is there a function that we can call in Java that gets the device's camera's height and width and the returned values will be assigned to the variables CAMERA_WIDTH and CAMERA_HEIGHT? or any ways to do it? aside from assigning it with real numbers. THANK YOU!
推荐答案
这是一个方法:
Camera.Parameters params = mCamera.getParameters(); // mCamera is a Camera object
List<Camera.Size> sizes = params.getSupportedPreviewSizes();
// position: variable where you choose between different supported resolutions,
// this varies from phone to phone, even the order can be different,
// ex. ascending or descending order.
mFrameWidth = (int) sizes.get(position).width;
mFrameHeight = (int) sizes.get(position).height;
params.setPreviewSize(mFrameWidth, mFrameHeight);
mCamera.setParameters(params);
这篇关于确定的Android设备上的相机高度和宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文