Search code examples
javascriptandroidandroid-webviewhtml5-fullscreen

WebView after closing fullscreen view, webview auto scrolls to top


I have webveiw (with fullscreen support) on the fragment. The issue is when i close fullscreen the webview scrolls it position to top. Noticed:

  • the issue appears only if apply FLAG_FULLSCREEN flag (but i need to apply it to have real fullscreen)
  • found possible solution is to use java script, but there is no answer. Also i'm not found the way to resolve this with webview functions like scrollTo and ect
  • when i add (instesad of fullscreen-view) view with small size (100dp height) i see that webview content is gone. Is it cached somwhere? Is it possible to disable this?

Solution

  • For me the issue was that webview have match_perent or wrap_content in height and after applying FLAG_FULLSCREEN webview lose it height. solution was to set layoutParams.height = height before set FLAG_FULLSCREEN

    so, in this case "layoutParams.height" - layout height settings, "height" - current view height