Determine Android Device's Camera Height and Width

前端 未结 1 1642
失恋的感觉
失恋的感觉 2021-01-22 07:38

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 heig

相关标签:
1条回答
  • 2021-01-22 08:25

    This is a way:

    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); 
    
    0 讨论(0)
提交回复
热议问题