关闭全屏视图后的WebView,Webview会自动滚动到顶部 [英] WebView after closing fullscreen view, webview auto scrolls to top
问题描述
我有webveiw
(具有全屏支持)分段.
问题是,当我关闭全屏时,webview会将其位置滚动到顶部.
注意:
I have webveiw
(with fullscreen support) on the fragment.
The issue is when i close fullscreen the webview scrolls it position to top.
Noticed:
- 仅当应用
FLAG_FULLSCREEN
标志时,问题才会出现(但我需要将其应用为真正的全屏显示) - 找到了可能的解决方案使用Java脚本,但没有答案.另外我也找不到用
scrollTo
和ect 之类的webview函数解决此问题的方法
- 当我添加小尺寸(高度100dp)的(全屏视图的安装)视图时,我看到Webview内容消失了.它在某处缓存了吗?可以禁用此功能吗?
- 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?
推荐答案
对我来说,问题是webview
的高度为match_perent or wrap_content
,并且在应用FLAG_FULLSCREEN
webview之后失去了高度.
解决方案是先设置layoutParams.height = height
,再设置FLAG_FULLSCREEN
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
因此,在这种情况下,"layoutParams.height"-布局高度设置,"height"-当前视图高度
so, in this case "layoutParams.height" - layout height settings, "height" - current view height
这篇关于关闭全屏视图后的WebView,Webview会自动滚动到顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!