I am a beginner in android studio and I need your help so I create a video player appliction but I have a problem with the orientation of the smartphone if you can help me to resize the demensions of the videoview in both cases (LANDSCAPE or PORTRAIT) it is necessary to remain the video in full screen and thank you very much
my code
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
Toast.makeText(getBaseContext(),"wa9fa",Toast.LENGTH_SHORT).show();
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
else if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE){
Toast.makeText(getBaseContext(),"na3sa",Toast.LENGTH_SHORT).show();
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
VideoView videoView = (VideoView)findViewById(R.id.videoView);
String path = "android.resource://" + getPackageName() + "/" + R.raw.track01;
videoView.setVideoURI(Uri.parse(path));
MediaController mediaController = new MediaController(this);
mediaController.setMediaPlayer(videoView);
mediaController.setAnchorView(videoView);
videoView.setMediaController(mediaController);
videoView.start();
}