How to prevent a scrollview from scrolling to a webview after data is loaded?

后端 未结 7 1698
梦如初夏
梦如初夏 2020-11-29 16:22

So I have a fascinating problem. Despite the fact that I\'m not manually or programmatically scrolling my view, my WebView is being automatically scrolled to after the data

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-29 16:43

    You should create new class extend ScrollView, then Override requestChildFocus:

    public class MyScrollView extends ScrollView {
    
        @Override 
        public void requestChildFocus(View child, View focused) { 
            if (focused instanceof WebView ) 
               return;
            super.requestChildFocus(child, focused);
        }
    }
    

    Then in your xml layout, using:

    
    

    That works for me. The ScrollView will not auto scroll to the WebView anymore.

提交回复
热议问题