public void OnVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) { try { if (!AppSettings.ShowVideoWithDynamicHeight) { return; } if (height > width) { height = GetPortraitHeight(height); } // Get layout params of view // Use MyView.this to refer to the current MyView instance // inside a callback var p = MainRoot.LayoutParameters; int currWidth = MainRoot.Width; // Set new width/height of view // height or width must be cast to float as int/int will give 0 // and distort view, e.g. 9/16 = 0 but 9.0/16 = 0.5625. // p.height is int hence the final cast to int. p.Width = currWidth; p.Height = (int)((float)height / width * currWidth); // Redraw myView MainRoot.RequestLayout(); } catch (Exception e) { Console.WriteLine(e); } }