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:minSdkVersionorandroid:targetSdkVersionattribute's value to"11".

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

  • Theandroid:splitMotionEventsattribute for view groups allows you to disable split touch events that occur between child views in a layout. For example:
    <LinearLayout android:splitMotionEvents="false" ... >   ... </LinearLayout>

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

  • Theandroid:windowEnableSplitTouchstyle property allows you to disable split touch events across windows, by applying it to a theme for the activity or entire application. For example:
    <style name="NoSplitMotionEvents" parent="android:Theme.Holo">   <item name="android:windowEnableSplitTouch">false</item>   ... </style>

    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 doesnotaffect 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.

    在Android中可以通过对一个Layout来设置SplintMotionEvents属性来决定同一个layout的子view是否可以响应同时点击。如果为false,表明不能响应同时点击事件,如果为true则代表可以。设置为true,在同时点击这个layout的两个子View,可以看到同时处于Focus状态。

更多相关文章

  1. drawlayout
  2. 重磅首发!Android(安卓)Jetpack Compose 完全开发手册,从入门到精
  3. HttpUrlConnect 响应为空的问题分析
  4. android 笔记 --- 自定义Android主题风格theme.xml方法
  5. OpenCV4 --Android(安卓)环境配置【详细教程】
  6. android EditText彻底搞定输入框隐藏/显示背景 可编辑输入问题
  7. Android重量级开发之--提高android启动速度研究
  8. Android(安卓)Studio使用教程、工程目录结构、使用注意事项、常
  9. Android(安卓)学习之一

随机推荐

  1. super(props) 真的那么重要吗?[每日前端夜
  2. 推荐一个基于 Node.js 的表单验证库 [每
  3. CSS粘性定位是怎样工作的 [每日前端夜话0
  4. python格式化输出:%s和format()用法比较
  5. 对比MySQL学习Pandas的groupby分组聚合
  6. 教你用Python拆分表格并发送邮件
  7. 实战!半小时写一个脑力小游戏 [每日前端夜
  8. 干货!python与MySQL数据库的交互实战
  9. 用python数据分析了北京积分落户名单,发现
  10. Python22个构造函数法-助力数据挖掘与分