Android Split touch events 禁用多点触控

                       

        分类:            笔记 784人阅读 评论(0) 收藏 举报

Split touch events

Previously, only a single view could accept touch events at one time. Android 3.0 adds support for splitting touch events across views and even windows, so different views can accept simultaneous touch events.

Split touch events is enabled by default when an application targets Android 3.0. That is, when the application has set either theandroid:minSdkVersion orandroid:targetSdkVersion attribute's value to"11".

However, the following properties allow you to disable split touch events across views inside specific view groups and across windows.

  • The android:splitMotionEvents attribute for view groups allows you to disable split touch events that occur between child views in a layout. For example:
    <span class="tag" style="color:#0088;"><LinearLayout</span><span class="pln" style="color:#000000;"> </span><span class="atn" style="color:#882288;">android:splitMotionEvents</span><span class="pun" style="color:#66660;">=</span><span class="atv" style="color:#8800;">"false"</span><span class="pln" style="color:#000000;"> ... </span><span class="tag" style="color:#0088;">></span><span class="pln" style="color:#000000;">
        ...
    </span><span class="tag" style="color:#0088;"></LinearLayout></span>

    This way, child views in the linear layout cannot split touch events—only one view can receive touch events at a time.

  • The android:windowEnableSplitTouch style property allows you to disable split touch events across windows, by applying it to a theme for the activity or entire application. For example:
    <span class="tag" style="color:#0088;"><style</span><span class="pln" style="color:#000000;"> </span><span class="atn" style="color:#882288;">name</span><span class="pun" style="color:#66660;">=</span><span class="atv" style="color:#8800;">"NoSplitMotionEvents"</span><span class="pln" style="color:#000000;"> </span><span class="atn" style="color:#882288;">parent</span><span class="pun" style="color:#66660;">=</span><span class="atv" style="color:#8800;">"android:Theme.Holo"</span><span class="tag" style="color:#0088;">></span><span class="pln" style="color:#000000;">
        </span><span class="pun" style="color:#66660;"><</span><span class="pln" style="color:#000000;">item name</span><span class="pun" style="color:#66660;">=</span><span class="str" style="color:#8800;">"android:windowEnableSplitTouch"</span><span class="pun" style="color:#66660;">></span><span class="pln" style="color:#000000;">false</span><span class="pun" style="color:#66660;"></</span><span class="pln" style="color:#000000;">item</span><span class="pun" style="color:#66660;">></span><span class="pln" style="color:#000000;">
        </span><span class="pun" style="color:#66660;">...</span><span class="pln" style="color:#000000;">
    </span><span class="tag" style="color:#0088;"></style></span>

    When this theme is applied to an <activity> or<application>, only touch events within the current activity window are accepted. For example, by disabling split touch events across windows, the system bar cannot receive touch events at the same time as the activity. This does not affect whether views inside the activity can split touch events—by default, the activity can still split touch events across views.

    For more information about creating a theme, readApplying Styles and Themes.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值