You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 02:13:39