Android的onTouchListener上的LinearLayout [英] Android onTouchListener on LinearLayout

查看:408
本文介绍了Android的onTouchListener上的LinearLayout的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有它几个子组件的线性布局。我对的LinearLayout onTouchListener。我想onTouch事件,当我接触到的线性布局的子组件也触发。

I have a linear layout with few child components in it. I have onTouchListener on the linearlayout. I want onTouch event to trigger when I touch child components of the linear layout too.

推荐答案

您应该能够实现<一个href=\"http://developer.android.com/reference/android/view/ViewGroup.html#onInterceptTouchEvent%28android.view.MotionEvent%29\"相对=nofollow>中的LinearLayout的自定义子类onInterceptTouchEvent 的方法来达到这种效果。从文档:

You should be able to implement the onInterceptTouchEvent method in a custom subclass of LinearLayout to achieve that effect. From the documentation:

公共布​​尔的 onInterceptTouchEvent (MotionEvent EV)

public boolean onInterceptTouchEvent (MotionEvent ev)

实现此方法可拦截所有触摸屏移动事件。这可以让你观看赛事,他们被分派到你的孩子,并采取目前的姿态所有权的任何一点。

Implement this method to intercept all touch screen motion events. This allows you to watch events as they are dispatched to your children, and take ownership of the current gesture at any point.

这篇关于Android的onTouchListener上的LinearLayout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆