A detailed explanation of issue can be understood from this question as the user had added image to explain it better.
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.
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.
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.
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.
I had tried many ways,
android:hardwareAccelerated="true"
in ManifestmWebView.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.
UPDATE -
After further googling it seems that this is a well-known issue in Honeycomb. This question also indicates the similar issue.
Seems there's no 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 every time. By which I was able to solve my issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With