如何动态收缩根据其内容web视图大小? [英] How to Shrink WebView size dynamically according to its content?

查看:177
本文介绍了如何动态收缩根据其内容web视图大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题的详细解释,可以从<一个可以理解href="http://stackoverflow.com/questions/3509158/scroll-view-doest-resize-when-the-content-of-child-view-changes">this 作为用户又增加了图像的问题来解释它更好的。

A detailed explanation of issue can be understood from this question as the user had added image to explain it better.

我在我的WebView加载HTML内容。我的布局,有许多观点和WebView功能的场所内滚动型(按设计要求)。请不要回答是 - 不要把里面的WebView滚动型。我知道,它不是一个好东西放的WebView里面滚动型,但按规定我必须这样做。

I am loading Html content in my WebView. My layout is having many view and WebView is place inside ScrollView(as per layout requirement). Please don't answer as - "Don't put WebView inside ScrollView". I know that its not a good thing to put WebView inside a ScrollView, but as per requirement I need to do so.

所以,我已经离开片段(显示列表项)和右片段(上选择从左侧片段列表项的显示数据反映)。现在,首先当我加载HTML内容里面WebV它显示正确。之后,当我刷新的WebView与新的HTML内容出现问题。

So, I have Left Fragment(showing List Items) and Right Fragment(Showing data reflected on selection of List Item from Left Fragment). Now, first of all when I load Html content inside WebV it shows correct. After that when I refresh WebView with new Html content the problem occurs.

假设,我的第一个HTML内容的100线它正确地显示,然后我重新加载的WebView与我的新的HTML内容这是40行则WebView功能不缩水和装修用40行的内容,它仍然为只要100线显示在底部白色/空白。

Suppose, my first Html content is of 100 lines it shows correctly and then I reload WebView with my new Html content which is of 40 lines then the WebView is not shrinking and fitting to the content with 40 lines, it still remains as long as 100 lines showing white/blank space at the bottom.

因此​​,似乎web视图能够重新大小本身从以下内容是previously加载到更多的内容,但不能重新尺寸本身当该含量小于previously加载的内容。

So, it seems that WebView is able to re-size itself from less content which is previously loaded to more content but unable to re-size itself when the content is less than previously loaded content.

我试过很多方法,

  • 添加安卓hardwareAccelerated =真正的在清单
  • 此博客
  • 还有很多其他的方式和博客
  • 此外,我曾试图用 mWebView.clearView(); 这将导致重新大小的WebView的大小,但有时web视图开始闪烁这仅仅是烦人。来此视频类似
  • Adding android:hardwareAccelerated="true" in Manifest
  • This Blog
  • Also many other ways and blog
  • Also I had tried to use mWebView.clearView(); which causes to re-size the size of WebView but at times the WebView start blinking which is just annoying. Similar to this video

不过,找不到任何妥善的解决办法。如果有人对你之前有同样的问题只是让我知道我可以申请的最佳解决方案。

But, couldn't find any proper solution. If anyone of you have the same issue before just let me know the best solution I could apply.

更新 -

在进一步谷歌搜索似乎这是在蜂窝一个众所周知的问题。 <一href="http://stackoverflow.com/questions/7467548/android-webview-is-making-problem-in-honeycomb">This问题也表明了类似的问题。

After further googling it seems that this is a well-known issue in Honeycomb. This question also indicates the similar issue.

推荐答案

有没有看起来的方式来调整的WebView(减少)的大小动态,一旦其加载。所以,这可以解决我的问题的唯一的事情就是重装完整的WebView。而不是在XML中定义的片段所以,我加入片段动态每次改变了我的东西。通过它我能解决我的问题。

There don't seems a way to resize the WebView(decrease) its size dynamically once its loaded. So, the only thing that could solve my problem was reloading the complete WebView. So, instead of defining the Fragment in xml I changed my stuff by adding Fragment dynamically everytime. By which I was able to solve my issue.

希望这可以帮助别人就是未来!

Hope this may help others is future!

这篇关于如何动态收缩根据其内容web视图大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆