MAUI中PinchZoom容器嵌套DrawingView的Android适配问题
MAUI中PinchZoom容器与DrawingView在Android平台的触摸事件冲突问题
在MAUI项目中使用PinchZoom容器包裹DrawingView时,iOS平台功能正常,但Android平台存在异常:DrawingView会捕获双指触摸事件,导致PinchZoom无法正常实现缩放操作。
已尝试的解决方案:
- 通过按钮切换DrawingView的启用/禁用状态
- 绑定
InputTransparent及CascadeInputTransparent属性
但Android端仅能成功切换一次,后续操作无法再生效,即使使用Dispatcher也无法解决该问题。
对应的XAML代码如下:
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:pinchZoom="using:PinchZoom" xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" x:Class="PinchZoom.MainPage" x:Name="View"> <Grid HorizontalOptions="Fill" VerticalOptions="Fill" BindingContext="{Binding Source={x:Reference Name=View}}"> <pinchZoom:PinchContainer IsClippedToBounds="True" HorizontalOptions="Center" VerticalOptions="Center" AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All"> <Grid> <Image Source="xp.jpg" Aspect="AspectFit"/> <toolkit:DrawingView BackgroundColor="Transparent" HorizontalOptions="Fill" VerticalOptions="Fill" IsMultiLineModeEnabled="True" ShouldClearOnFinish="False" /> </Grid> </pinchZoom:PinchContainer> </Grid> </ContentPage>
内容的提问来源于stack exchange,提问作者Austin Oberholtzer
相关产品推荐
相关产品推荐

