横長モードで縦横比の動画を再生したい。だから、私は次のように書いた。
landscape = true;
// Get the dimensions of the video
int videoWidth = mediaPlayer.getVideoWidth();
int videoHeight = mediaPlayer.getVideoHeight();
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
lp = surfaceView.getLayoutParams();
lp.width = (int) (videoProportion * (float) screenHeight);
lp.height = screenHeight;
mVideoWidth = lp.width;
mVideoHeight = lp.height;
// Commit the layout parameters
surfaceView.setLayoutParams(lp);
holder.setFixedSize(mVideoWidth, mVideoHeight); '
そのため、ビデオは横向きで再生されますが、位置は残されています。ポジションはセンターでお願いします。どのように実装しますか?