我在Xamarin Forms中有两页使用自定义渲染器在每个页面上显示Android VideoView。第1页上的视频(嵌套在RelativeLayout内)成功播放。当我使用Navigation.PushAsync(Page2);
从第1页导航到第2页时,Page1中的VideoView继续与第2页上的视频重叠。Android VideoView重叠
有没有办法强制VideoView尊重其父视图容器的可见性?
的Page1.xaml:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MyVideoApp.Page1">
<RelativeLayout>
<MyVideoView x:Name="vidPlayer" Source="http://...."
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height}" />
</RelativeLayout>
</ContentPage>
Page2.xaml:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MyVideoApp.Page2">
<MyVideoView x:Name="vidPlayer" Source="http://...." />
</ContentPage>
我已经尝试使用OnAppearing()和OnDisapearing()在Xamarin窗体页面浏览到第二页,但没有成功,当玩家的知名度,设置为false。 VideoView.setZOrderMediaOverlay(true)VideoView.setTranslationZ() VideoView.setZOrderOnTop()方法也不能解决问题。 – Adam
基于我发现的关于SurfaceView,听起来像是在能见度回来时摧毁和创建它,这将是要走的路,但不知道这完全是什么样子。 – Adam