Scroll Webview inside a Scroll View

后端 未结 4 1890
心在旅途
心在旅途 2021-01-12 19:57

What I have:
Right now I have a Scroll view as a parent. Inside this scroll view, I am using a WebView that loads a URL and then shows text in it. Here

4条回答
  •  清歌不尽
    2021-01-12 20:29

    Create a Custom Touch Intercepting Webview

    CustomWebview.java

     package com.mypackage.common.custom.android.widgets
    
    public class CustomWebview extends WebView {
    
        public CustomWebview(Context context) {
            super(context);
        }
    
        public CustomWebview(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
    
        public CustomWebview(Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);
        }
    
        @Override
        public boolean onTouchEvent(MotionEvent event){
            requestDisallowInterceptTouchEvent(true);
            return super.onTouchEvent(event);
        }          
    }
    

    in layout.xml

    
    

提交回复
热议问题