WebView jump to anchor using loadDataWithBaseUrl

后端 未结 5 1347
名媛妹妹
名媛妹妹 2021-01-02 10:25

My Android app uses a WebView to display a bunch of HTML code that I generate \'on the fly\'. The HTML code is loaded using the following code:



        
5条回答
  •  庸人自扰
    2021-01-02 11:25

    If you have in your layout the webview inside a nestedScrollView the nesting will prevent the scrolling events from working properly. Once you take it out it will work without any need to reload or add javascript.

    Additionally if you want to keep the nestedScrollView and dont care if the user cannot scroll past that section you can add fillViewPort=true to the nestedScrollView and android:layout_height="wrap_content" to the webview.

    It would look something like:

    
    
      
      ...
      
    
      
    
          
    
      
    
    
    
    

提交回复
热议问题