在webview中,覆盖TouchListener

时间:2012-04-24 07:32:05

标签: android webview ontouchlistener

我在android中使用webview

需要识别它是否滚动

滚动webview时,隐藏我的选项标签并停止滚动,设置可见的webview。

   www.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub  
            if(event.getAction() == MotionEvent.ACTION_UP)
            {
                Log.v("motion", "Up");
                option_tab_layout.setVisibility(View.VISIBLE);
            }
            if(event.getAction()==MotionEvent.ACTION_MOVE){
                Log.v("motion", "move");
                option_tab_layout.setVisibility(View.INVISIBLE);
            }
            return false;
        }
    });

当返回false时,ACTION_UP事件没有调用, 并且使用return true,webview无法滚动页面

我该怎样处理它?<​​/ p>

1 个答案:

答案 0 :(得分:1)

我宁愿使用onScrollChanged (int l, int t, int oldl, int oldt)

Doc here:http://developer.android.com/reference/android/webkit/WebView.html#onScrollChanged(int,int,int,int)