I have some code that will run when the orientation changes:
@Override
public void onConfigurationChanged(Configuration newConfig){
super.onConfigurationChanged(newConfig);
setVideoSize();
_videoSurfaceView.changeCameraDisplaySize();
}
private void setVideoSize() {
//Get the dimensions of the video
int videoWidth = _videoSurfaceView.getCamera().getParameters().getPreferredPreviewSizeForVideo().width;
int videoHeight = _videoSurfaceView.getCamera().getParameters().getPreferredPreviewSizeForVideo().height;
float videoProportion = (float) videoWidth / (float) videoHeight;
// Get the width of the screen
int screenWidth = getWindowManager().getDefaultDisplay().getWidth();
int screenHeight = getWindowManager().getDefaultDisplay().getHeight();
float screenProportion = (float) screenWidth / (float) screenHeight;
// Get the SurfaceView layout parameters
android.view.ViewGroup.LayoutParams lp = _videoSurfaceView.getLayoutParams();
if (videoProportion > screenProportion) {
lp.width = screenWidth;
lp.height = (int) ((float) screenWidth / videoProportion);
} else {
lp.width = (int) (videoProportion * (float) screenHeight);
lp.height = screenHeight;
}
// Commit the layout parameters
_videoSurfaceView.setLayoutParams(lp);
}
This is called when a rotation occurs, but I need to run setVideoSize() after the rotation is complete. Is there a way to do this?