2013年8月19日 星期一

Relative Layout Touch Listener


It may that something in your view is "on top" of myRelativeLayout. If it is, it's getting the touch event first. The worst part about that is that the default handling of events is to do nothing with the event and then consume it.
One solution would be to add this code onto whatever components of your display are "above" the View (or Layout) that SHOULD handle the event:
someView.setOnTouchListener (new View.OnTouchListener()
{
    @Override
    public boolean onTouch (View v, MotionEvent event)
    {
        return false;
    }
});
The key (obviously) is to return false. When you do that, the event will not be consumed, but rather passed "down" to something in your relative layout -- hopefully somewhere you want it to go.
share|improve this answer

沒有留言:

張貼留言

Related Posts Plugin for WordPress, Blogger...