我在Xamarin Forms中有两个页面,使用自定义渲染器在每个页面上显示Android VideoView。第1页上的视频(嵌套在RelativeLayout中)可以成功播放。当我使用Navigation.PushAsync(Page2);
从Page1导航到Page2时,Page1的VideoView继续与Page2上的视频重叠。
有没有办法强制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>
答案 0 :(得分:0)
VideoView
是SurfaceView
和SurfaceView
的Z顺序是在附加到窗口之前确定的,之后无法更改。因此,自SurfaceView
类型的节目通过任何内容和所有内容以来,您不能同时显示多个SurfaceView
。
您可能需要尝试完全删除VideoView
并稍后重新添加,或者如果其他所有方法都失败,您可以尝试将VideoView
移出屏幕。