Note that there are some explanatory texts on larger screens.

plurals
  1. POAspect Ratio wrong after onResume()
    primarykey
    data
    text
    <p>I am having a problem. The aspect ratio of my media player becomes messed up after onResume is called</p> <pre><code>private void aspectRatio(MediaPlayer vp) { Integer videoHeight; Integer videoWidth; //Obtain current video's dimensions for keeping aspect Ration the same on all devices videoHeight = vp.getVideoHeight(); videoWidth = vp.getVideoWidth(); //Get width of screen Integer screenWidth = getWindowManager().getDefaultDisplay().getWidth(); Integer screenHeight = getWindowManager().getDefaultDisplay().getHeight(); Log.i("AspectRatio VP WxH", videoHeight.toString() +" x " + videoWidth.toString()); Log.i("AspectRatio Screen WxH", screenHeight.toString() + " x " + screenWidth.toString()); ViewGroup.LayoutParams viewParameters = view.getLayoutParams(); float ratioWidth = (float)screenWidth/(float)videoWidth; float ratioHeight = (float)screenHeight/(float)videoHeight; float aspectRatio = (float)videoWidth/(float)videoHeight; if(ratioWidth&gt;ratioHeight) { viewParameters.width = (int)(screenHeight * aspectRatio); viewParameters.height= screenHeight; } else if(ratioWidth &lt; ratioHeight) { viewParameters.width = screenWidth; viewParameters.height = (int) (screenHeight / aspectRatio); } Integer x = viewParameters.width; Integer y = viewParameters.height; Log.i("Screen", x.toString() + " " + y.toString()); view.setLayoutParams(viewParameters); } </code></pre> <p>that was the function that gets the aspect ratio and puts it to my surfaceView. The problem is that after onResume() its width is much smaller than it is supposed to be. Can yuou see what is wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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