Scroll view doesn't resize when the content of child view changes

本秂侑毒 提交于 2020-01-01 08:42:30

问题


I have a WebView inside the ScrollView.

The content of WebView dyanamically changes when it displays different html page.

I have the following issue:

For example I have A.html, and B.html. The content of B.html is larger than A.html, so the page is longer.

When WebView load B.html, the ScrollView stretches its size to enable itself scroll for B.html, then if I go back to A.html, ScrollView doesn't resize itself. (The scroll area is exceed the content of A.html)

What I want to have, is dynamic change the scroll area of scroll view to fit the webview's content.


回答1:


That's not good idea to place WebView inside of ScrollView. WebView is smart enough to show scrollbars by itself.




回答2:


Try using android:fillViewport in scroll view..!!

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scroller"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true" >



回答3:


After Orientation screen will resize, it works but bad in performance, not a very good solution

setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE );
setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_SENSOR );



回答4:


Don't put a WebView inside of a ScrollView.



来源:https://stackoverflow.com/questions/3509158/scroll-view-doesnt-resize-when-the-content-of-child-view-changes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!