admin管理员组文章数量:1389758
After having a video played in CommunityToolkit MediaPlayer full screen on Android the height and/or width of the Page and AppShell changes.
It also happens in CommunityToolkit's own example app.
The OnSizeAllocated is fired when minimizing the video:
protected override void OnSizeAllocated(double width, double height)
{
base.OnSizeAllocated(width, height);
//respond to size change below...
}
I have tried to force the page size through HeightRequest, however, it the height does not change:
var page = Shell.Current.CurrentPage;
page.HeightRequest = 1000;
var p = this;
p.HeightRequest = 1000;
I have added an issue on Git (). While waiting for a fix my question is if I can force the page height back to the original to remove the spacing?
- .NET MAUI CommunityToolkit MediaElement: 6.0.1
- .NET MAUI: 9.0.40
Thanks!
After having a video played in CommunityToolkit MediaPlayer full screen on Android the height and/or width of the Page and AppShell changes.
It also happens in CommunityToolkit's own example app.
The OnSizeAllocated is fired when minimizing the video:
protected override void OnSizeAllocated(double width, double height)
{
base.OnSizeAllocated(width, height);
//respond to size change below...
}
I have tried to force the page size through HeightRequest, however, it the height does not change:
var page = Shell.Current.CurrentPage;
page.HeightRequest = 1000;
var p = this;
p.HeightRequest = 1000;
I have added an issue on Git (https://github/CommunityToolkit/Maui/issues/2571). While waiting for a fix my question is if I can force the page height back to the original to remove the spacing?
- .NET MAUI CommunityToolkit MediaElement: 6.0.1
- .NET MAUI: 9.0.40
Thanks!
Share Improve this question asked Mar 12 at 17:46 Kasper SommerKasper Sommer 4631 gold badge9 silver badges20 bronze badges1 Answer
Reset to default 0I cloned the sample you provided in the issue link. What I found:
The .NET MAUI CommunityToolkit MediaElement: 6.0.1 can't work in my side and I used .NET MAUI CommunityToolkit MediaElement: 5.0.0 instead.
This problem only appear in the Android Version that lower than Android 15.0. The UI will not change after full screen the mediaelement and exit it on Android 15.0.
There is only bottom blank space in my side. There is no top blank space in my test. In addition, the height of the bottom blank space is equal to the height of the android bottom navigation bar.
The code to get the height of android bottom navigation bar:
var statusid = Platform.CurrentActivity.ApplicationContext.Resources.GetIdentifier("status_bar_height", "dimen", "android");
var statusbarheight = Platform.CurrentActivity.ApplicationContext.Resources.GetDimensionPixelSize(statusid);
// this is the status bar height
var navid = Platform.CurrentActivity.ApplicationContext.Resources.GetIdentifier("navigation_bar_height", "dimen", "android");
var navbarheight = Platform.CurrentActivity.ApplicationContext.Resources.GetDimensionPixelSize(navid);
// this is the navigation bar height
And as you said:
The OnSizeAllocated is fired when minimizing the video:
So I get the D-value between full screen video and minimizing the video:
protected override void OnSizeAllocated(double width, double height)
{
base.OnSizeAllocated(width, height);
var height = (this.Handler.PlatformView as Android.Views.View).Height;
// the heights are different when max and min
}
So you can try to full screen your app to avoid the blank space. Put the following code in the MainActivity:
protected override void OnCreate(Bundle? savedInstanceState)
{
base.OnCreate(savedInstanceState);
Window.SetFlags(WindowManagerFlags.LayoutNoLimits, WindowManagerFlags.LayoutNoLimits);
Window.Attributes.LayoutInDisplayCutoutMode = LayoutInDisplayCutoutMode.ShortEdges;
Window.DecorView.SystemUiFlags =
(SystemUiFlags.ImmersiveSticky | SystemUiFlags.HideNavigation |
SystemUiFlags.Fullscreen | SystemUiFlags.Immersive);
}
You can also follow up the issue you opened on the github repo.
The released PR fix can resolve this issue.
本文标签: mauiAndroid Page height and width of app changes after full screen videoStack Overflow
版权声明:本文标题:maui - Android Page height and width of app changes after full screen video - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744736084a2622335.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论