Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You should add your videoview (or content Parent) as last element in your layout file. and use the next code:</p> <pre><code>private RelativeLayout.LayoutParams paramsNotFullscreen; //if you're using RelativeLatout @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) //To fullscreen { paramsNotFullscreen=(RelativeLayout.LayoutParams)mVideoView.getLayoutParams(); RelativeLayout.LayoutParams params=new LayoutParams(paramsNotFullscreen); params.setMargins(0, 0, 0, 0); params.height=ViewGroup.LayoutParams.MATCH_PARENT; params.width=ViewGroup.LayoutParams.MATCH_PARENT; params.addRule(RelativeLayout.CENTER_IN_PARENT); mVideoView.setLayoutParams(params); } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { mVideoView.setLayoutParams(paramsNotFullscreen); } } </code></pre> <p>It gets a copy of videoview layoutparams and saves it in a global variable. then creates a new layoutparams object with the previous values but setting now the limits to match_parent and sets it in your videoview. You videoview now is in fullscreen. When you put your device in portrait, paramsNotFullscreen restores previous values.</p> <p><strong>UPDATE:</strong></p> <p>In your manifest file you must add into Activity declaration the following code to avoid the activity restart:</p> <pre><code>android:configChanges="screenLayout|screenSize|orientation" </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload