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 the android:minSdkVersion or android: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: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.
- The
android: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 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, read Applying Styles and Themes.
Android 3.0 引入了触摸事件拆分功能,允许不同视图同时接收触摸输入。默认情况下,针对 Android 3.0 的应用会启用此功能。可以通过设置 viewgroup 的 android:splitMotionEvents 属性或应用样式属性 android:windowEnableSplitTouch 来禁用特定布局或窗口上的触摸事件拆分。
1293

被折叠的 条评论
为什么被折叠?



