如何改变在Android的一个web视图的内容大小?视图、大小、内容、Android

2023-09-07 10:15:27 作者:ゞ你不想要、我也懒得给

我有一个滚动视图一个WebView控件。当我加载一个长期html文件到它,它会调整,以适应它。这是对的。然而,当我使用相同的控制之后又放少占用空间的HTML到它的内容的大小并没有缩水。这是一个问题,因为用户能够依然滚动短文档转换为空白。关于如何解决这个任何想法?

I have a webview control in a scrollview. when i load a long html document into it, it resizes to accommodate it. this is correct. however, when i use the same control again afterwards and put less space-consuming html into it, the content size doesn't shrink. this is a problem because the user is able to still scroll a short document into white space. any ideas on how to resolve this?

推荐答案

我也有类似的问题,并通过清除视图和重新测量与前再次加载视图中的小尺寸解决它。

I had a similar problem and resolved it by clearing the view and re-measuring with a small size prior to loading the view again.

例如。

  webView.clearView();
  webView.measure(10, 10);